Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
78a3feda
Unverified
Commit
78a3feda
authored
Sep 17, 2025
by
Yan Ru Pei
Committed by
GitHub
Sep 17, 2025
Browse files
fix: hook up worker removals for indexer (#3095)
Signed-off-by:
PeaBrane
<
yanrpei@gmail.com
>
parent
26889b09
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
0 deletions
+44
-0
lib/bindings/python/rust/llm/kv.rs
lib/bindings/python/rust/llm/kv.rs
+1
-0
lib/llm/src/kv_router.rs
lib/llm/src/kv_router.rs
+1
-0
lib/llm/src/kv_router/indexer.rs
lib/llm/src/kv_router/indexer.rs
+9
-0
lib/llm/src/kv_router/subscriber.rs
lib/llm/src/kv_router/subscriber.rs
+33
-0
No files found.
lib/bindings/python/rust/llm/kv.rs
View file @
78a3feda
...
...
@@ -419,6 +419,7 @@ impl KvIndexer {
component
.inner
.clone
(),
consumer_uuid
.unwrap_or_else
(||
uuid
::
Uuid
::
new_v4
()
.to_string
()),
inner
.event_sender
(),
inner
.remove_worker_sender
(),
None
,
cancellation_token
,
None
,
...
...
lib/llm/src/kv_router.rs
View file @
78a3feda
...
...
@@ -266,6 +266,7 @@ impl KvRouter {
component
.clone
(),
consumer_uuid
,
kv_indexer
.event_sender
(),
kv_indexer
.remove_worker_sender
(),
kv_router_config
.router_snapshot_threshold
.map
(|
_
|
kv_indexer
.snapshot_event_sender
()),
...
...
lib/llm/src/kv_router/indexer.rs
View file @
78a3feda
...
...
@@ -874,6 +874,15 @@ impl KvIndexer {
pub
fn
snapshot_event_sender
(
&
self
)
->
mpsc
::
Sender
<
DumpRequest
>
{
self
.dump_tx
.clone
()
}
/// Get a sender for worker removal requests.
///
/// ### Returns
///
/// A `mpsc::Sender` for `WorkerId`s.
pub
fn
remove_worker_sender
(
&
self
)
->
mpsc
::
Sender
<
WorkerId
>
{
self
.remove_worker_tx
.clone
()
}
}
#[async_trait]
...
...
lib/llm/src/kv_router/subscriber.rs
View file @
78a3feda
...
...
@@ -68,10 +68,12 @@ impl SnapshotResources {
}
/// Start a unified background task for event consumption and optional snapshot management
#[allow(clippy::too_many_arguments)]
pub
async
fn
start_kv_router_background
(
component
:
Component
,
consumer_uuid
:
String
,
kv_events_tx
:
mpsc
::
Sender
<
RouterEvent
>
,
remove_worker_tx
:
mpsc
::
Sender
<
crate
::
kv_router
::
indexer
::
WorkerId
>
,
snapshot_tx
:
Option
<
mpsc
::
Sender
<
DumpRequest
>>
,
cancellation_token
:
CancellationToken
,
router_snapshot_threshold
:
Option
<
u32
>
,
...
...
@@ -156,6 +158,13 @@ pub async fn start_kv_router_background(
.dissolve
();
let
cleanup_lock_name
=
format!
(
"{}/{}"
,
ROUTER_CLEANUP_LOCK
,
component
.subject
());
// Get the generate endpoint and watch for instance deletions
let
generate_endpoint
=
component
.endpoint
(
"generate"
);
let
(
_
instance_prefix
,
_
instance_watcher
,
mut
instance_event_rx
)
=
etcd_client
.kv_get_and_watch_prefix
(
generate_endpoint
.etcd_root
())
.await
?
.dissolve
();
// Only set up snapshot-related resources if snapshot_tx is provided and threshold is set
let
snapshot_resources
=
if
snapshot_tx
.is_some
()
&&
router_snapshot_threshold
.is_some
()
{
let
lock_name
=
format!
(
"{}/{}"
,
ROUTER_SNAPSHOT_LOCK
,
component
.subject
());
...
...
@@ -188,6 +197,30 @@ pub async fn start_kv_router_background(
break
;
}
// Handle generate endpoint instance deletion events
Some
(
event
)
=
instance_event_rx
.recv
()
=>
{
let
WatchEvent
::
Delete
(
kv
)
=
event
else
{
continue
;
};
let
key
=
String
::
from_utf8_lossy
(
kv
.key
());
let
Some
(
worker_id_str
)
=
key
.split
(
'/'
)
.next_back
()
else
{
tracing
::
warn!
(
"Could not extract worker ID from instance key: {}"
,
key
);
continue
;
};
let
Ok
(
worker_id
)
=
worker_id_str
.parse
::
<
i64
>
()
else
{
tracing
::
warn!
(
"Could not parse worker ID from instance key: {}"
,
key
);
continue
;
};
tracing
::
info!
(
"Generate endpoint instance deleted, removing worker {}"
,
worker_id
);
if
let
Err
(
e
)
=
remove_worker_tx
.send
(
worker_id
)
.await
{
tracing
::
warn!
(
"Failed to send worker removal for worker {}: {}"
,
worker_id
,
e
);
}
}
// Handle event consumption
result
=
nats_queue
.dequeue_task
(
None
)
=>
{
match
result
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment