-
Notifications
You must be signed in to change notification settings - Fork 646
feat: register Kv router instance into etcd #2548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds dynamic-mode persistence for KV router configs: when creating a KvRouter, ModelManager fetches etcd from the distributed runtime, serializes the router config to JSON, and writes it under a generated key. Fails if etcd is unavailable. Also adds serde derives to KvRouterConfig to enable serialization. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant MM as ModelManager
participant DRT as DistributedRuntimeProvider
participant ETCD as etcd
participant KR as KvRouter
Caller->>MM: create_kv_chooser(model_name, kv_router_config)
MM->>DRT: drt().etcd_client()
alt etcd client available
MM->>MM: generate router_key (model_name + UUID)
MM->>MM: serialize kv_router_config → JSON
MM->>ETCD: kv_create(router_key, JSON)
ETCD-->>MM: ack/result
MM->>KR: instantiate KvRouter
MM-->>Caller: return KvRouter
else etcd unavailable
MM-->>Caller: error "KV routing requires etcd (dynamic mode)"
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
lib/llm/src/kv_router.rs (1)
77-90
: Add#[serde(default)]
for forward/backward compatibility when reading from etcd.When you later read entries written to etcd, missing fields in older configs will deserialize to defaults instead of failing.
Apply:
-#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +#[serde(default)] pub struct KvRouterConfig {lib/llm/src/discovery/model_manager.rs (2)
230-242
: Use a constant for thekv_routers/
prefix.Keeps paths consistent and discoverable next to other KV router constants.
Example:
Define in
kv_router.rs
(near other constants):
pub const KV_ROUTERS_ROOT_PATH: &str = "kv_routers";
Use here:
- let router_key = format!("kv_routers/{}/{}", model_name, uuid::Uuid::new_v4()); + let router_key = format!("{}/{}/{}", KV_ROUTERS_ROOT_PATH, model_name, uuid::Uuid::new_v4());
230-242
: Prefer compact JSON for etcd values.Pretty-printing increases payload and network/storage overhead with no runtime benefit.
- serde_json::to_vec_pretty(&kv_router_config.unwrap_or_default())?, + serde_json::to_vec(&kv_router_config.unwrap_or_default())?,
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
lib/llm/src/discovery/model_manager.rs
(2 hunks)lib/llm/src/kv_router.rs
(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
lib/llm/src/discovery/model_manager.rs (3)
lib/bindings/python/rust/lib.rs (1)
etcd_client
(315-320)lib/llm/src/http/service/service_v2.rs (1)
etcd_client
(114-116)lib/runtime/src/transports/etcd.rs (1)
etcd_client
(142-144)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Build and Test - dynamo
- GitHub Check: pre-merge-rust (.)
- GitHub Check: pre-merge-rust (lib/runtime/examples)
- GitHub Check: pre-merge-rust (lib/bindings/python)
🔇 Additional comments (3)
lib/llm/src/kv_router.rs (1)
19-19
: Serde derive feature and serde_json dependency confirmed
Verified that the root Cargo.toml declares
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1" }
and that
lib/llm
pulls both in viaworkspace = true
. No further changes required.lib/llm/src/discovery/model_manager.rs (2)
5-5
: Trait import LGTM.Importing
DistributedRuntimeProvider
is necessary to callcomponent.drt()
.
230-242
: Lease semantics and UUID dependency verified
kv_create
’s signature iskv_create(&self, key: &str, value: Vec<u8>, lease_id: Option<i64>)
, andNone
unwraps toself.lease_id()
, correctly attaching the primary lease as intended.- The
uuid
crate is declared inCargo.toml
(workspace) and available for use.
b2e4627
to
ade9c6b
Compare
Signed-off-by: Hannah Zhang <[email protected]>
Signed-off-by: Krishnan Prashanth <[email protected]>
Signed-off-by: nnshah1 <[email protected]>
Motivation
The motivation for this is to prepare for router replica warm restarts. KV router needs to be aware of the existence (and healthiness) of other KV routers, so they can properly coordinate dumping their
RadixTree
states and loading them back.Changes
Register an instance of KV router under the
kv_routers/
prefix upon successful creation of aKvRouter
increate_kv_chooser
E2E tests
In pre-merge CI, verify that one Router gets you one key with prefix
kv_routers/
and two Router replicas get you two keys with prefixkv_routers/
😃Summary by CodeRabbit