Skip to content

Conversation

@ryanolson
Copy link
Contributor

@ryanolson ryanolson commented Jun 10, 2025

Relocates KvStore from llm -> runtime

Summary by CodeRabbit

  • New Features

    • Introduced hierarchical namespace support with fully qualified names and parent relationships.
    • Added comprehensive etcd path parsing, validation, and construction, including support for reserved keywords, lease IDs, and extra path segments.
    • Exposed new public modules for storage and key-value store management.
  • Improvements

    • Enhanced validation for allowed characters in namespace and component names.
    • Improved etcd path construction and management for components and endpoints.
    • Updated internal references to use local modules for better maintainability.
    • Restricted visibility of certain internal methods for improved encapsulation.
  • Bug Fixes

    • Ensured consistent and validated etcd path formatting throughout the system.
  • Tests

    • Added integration tests for hierarchical namespaces and component etcd path correctness.

@copy-pr-bot
Copy link

copy-pr-bot bot commented Jun 10, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 11, 2025

Walkthrough

The changes introduce a comprehensive restructuring of etcd path handling in the distributed runtime, including a new EtcdPath abstraction for hierarchical namespaces, components, and endpoints. Imports are reorganized for clarity and consistency. The storage module is now public, and new validation and test logic ensures correct path formatting and hierarchical structure.

Changes

File(s) Change Summary
lib/llm/src/discovery/model_entry.rs
lib/llm/src/local_model.rs
lib/llm/src/model_card/model.rs
Consolidated and reorganized imports to group all dynamo_runtime related imports together. Removed local imports of key-value store traits and structs, relying solely on dynamo_runtime. No logic changes.
lib/llm/src/lib.rs Commented out pub mod key_value_store;, removing the public export of the key_value_store module from this crate.
lib/runtime/src/component.rs Major enhancements: introduced EtcdPath usage for etcd path management, changed runtime references to Arc, added hierarchical namespace support with parent tracking, implemented validation on names, and added methods for constructing and retrieving etcd paths and fully qualified names. Enhanced struct fields and added new methods for components, endpoints, and namespaces.
lib/runtime/src/component/endpoint.rs Updated usage of endpoint etcd path methods to use the new etcd_path_with_lease_id method. No other logic changes.
lib/runtime/src/distributed.rs Added a comment indicating future deprecation plans for the etcd_client getter. No code changes.
lib/runtime/src/lib.rs Added pub mod storage;, making the storage module publicly accessible.
lib/runtime/src/storage.rs New file: Declares and publicly exposes the key_value_store submodule.
lib/runtime/src/storage/key_value_store.rs
lib/runtime/src/storage/key_value_store/etcd.rs
lib/runtime/src/storage/key_value_store/nats.rs
Changed imports from external crate dynamo_runtime to local crate-relative imports for Slug, CancellationToken, and client types. Updated logging initialization to use the local crate. No logic changes.
lib/runtime/src/transports/etcd.rs Added import and public re-export of new path module. Changed Client::etcd_client() method visibility from public to crate-private.
lib/runtime/src/transports/etcd/path.rs New file: Introduces the EtcdPath struct and related error types for parsing, validating, and constructing hierarchical etcd paths with reserved keywords and lease ID support. Implements strict validation, parsing, formatting, and conversion logic, with comprehensive unit tests.
lib/runtime/tests/namespace_etcd_path.rs New test file: Adds integration tests for recursive namespace and component etcd path construction, validating correct formatting, hierarchical structure, and uniqueness across branches.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DistributedRuntime
    participant Namespace
    participant Component
    participant Endpoint
    participant EtcdPath

    User->>DistributedRuntime: create_namespace(name)
    DistributedRuntime->>Namespace: new(name, parent)
    Namespace->>EtcdPath: etcd_path()
    EtcdPath-->>Namespace: returns path string

    User->>Namespace: create_component(name)
    Namespace->>Component: new(name, runtime)
    Component->>EtcdPath: etcd_path()
    EtcdPath-->>Component: returns path string

    User->>Component: create_endpoint(name)
    Component->>Endpoint: new(name, component)
    Endpoint->>EtcdPath: etcd_path()
    EtcdPath-->>Endpoint: returns path string
Loading

Poem

In the warren of code, new paths now appear,
Etcd roots and namespaces, all crystal clear.
Components and endpoints, with names validated,
Arc-shared runtimes, no longer outdated.
With tests for each branch, and paths nested deep,
This bunny’s delighted—these changes will keep!
🐇🌱


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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🔭 Outside diff range comments (1)
lib/runtime/src/component.rs (1)

489-499: 🛠️ Refactor suggestion

Consolidate duplicate validation logic.

This validate_allowed_chars function duplicates the logic in path.rs. Consider moving it to a shared module or reusing the one from path.rs.

Move the validation function to a common module (e.g., validation.rs) and import it in both files to maintain DRY principles.

🧹 Nitpick comments (2)
lib/runtime/src/lib.rs (1)

47-47: Add a doc comment for the new storage module. Since storage is part of the public API, a brief doc comment will clarify its role.

-    pub mod storage;
+    /// Storage module exposing key-value store implementations (etcd, NATS).
+    pub mod storage;
lib/llm/src/lib.rs (1)

21-21: Clean up the commented-out module. Rather than leaving a disabled pub mod key_value_store;, remove it to keep the codebase tidy and avoid confusion.

-// pub mod key_value_store;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e32fe67 and 50890a2.

📒 Files selected for processing (15)
  • lib/llm/src/discovery/model_entry.rs (1 hunks)
  • lib/llm/src/lib.rs (1 hunks)
  • lib/llm/src/local_model.rs (1 hunks)
  • lib/llm/src/model_card/model.rs (1 hunks)
  • lib/runtime/src/component.rs (12 hunks)
  • lib/runtime/src/component/endpoint.rs (2 hunks)
  • lib/runtime/src/distributed.rs (1 hunks)
  • lib/runtime/src/lib.rs (1 hunks)
  • lib/runtime/src/storage.rs (1 hunks)
  • lib/runtime/src/storage/key_value_store.rs (2 hunks)
  • lib/runtime/src/storage/key_value_store/etcd.rs (1 hunks)
  • lib/runtime/src/storage/key_value_store/nats.rs (1 hunks)
  • lib/runtime/src/transports/etcd.rs (2 hunks)
  • lib/runtime/src/transports/etcd/path.rs (1 hunks)
  • lib/runtime/tests/namespace_etcd_path.rs (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Rust pre-merge checks
lib/runtime/tests/namespace_etcd_path.rs

[error] 5-5: unused imports: DistributedRuntime and Runtime. To override, add #[allow(unused_imports)].

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test - vllm
🔇 Additional comments (15)
lib/runtime/src/storage/key_value_store/etcd.rs (1)

20-20: Localize imports for consistency. Importing Slug and Client from the local crate (instead of dynamo_runtime) ensures internal coherence and removes external dependencies.

lib/runtime/src/storage/key_value_store/nats.rs (1)

18-18: Switch to crate-relative imports. Using crate::{protocols::Endpoint, slug::Slug, transports::nats::Client} aligns with the runtime's module structure and replaces the old external references.

lib/runtime/src/storage.rs (1)

4-4:

Details

✅ Verification successful

Ensure storage module is re-exported: The new pub mod key_value_store should be reachable via runtime::storage. Confirm that lib/runtime/src/lib.rs contains pub mod storage;.


🏁 Script executed:

#!/bin/bash
# Verify that the storage module is exposed in the crate root
rg -n "pub mod storage" lib/runtime/src/lib.rs

Length of output: 68


storage module re-export confirmed

Confirmed that lib/runtime/src/lib.rs includes pub mod storage; on line 47, making runtime::storage::key_value_store accessible as intended.

lib/runtime/src/storage/key_value_store.rs (1)

315-315:

Details

✅ Verification successful

Update logging init call in tests: Using crate::logging::init() aligns with the refactored logging module. Ensure logging is exported from the runtime crate so tests can invoke it.


🏁 Script executed:

#!/bin/bash
# Verify that logging module is publicly available
rg -n "pub mod logging" lib/runtime/src/lib.rs

Length of output: 68


Logging module export confirmed
The pub mod logging; declaration is present at line 39 in lib/runtime/src/lib.rs, so using crate::logging::init() in tests is valid.

lib/llm/src/discovery/model_entry.rs (1)

7-11: Consolidated dynamo_runtime imports: The grouped import of protocols, Slug, and key-value store types from dynamo_runtime reflects the new module location and reduces local crate coupling.

lib/llm/src/local_model.rs (1)

9-12: Grouped dynamo_runtime imports: Importing Component, Endpoint, and key-value store traits from dynamo_runtime in one statement improves readability and aligns with the refactor.

lib/llm/src/model_card/model.rs (1)

24-24: Updated runtime imports: The consolidated import of Slug, Versioned, and nats from dynamo_runtime accurately reflects the relocated key-value store and transport modules.

lib/runtime/src/transports/etcd.rs (1)

35-38: LGTM! Clean module organization.

The addition of the path module and its public re-export follows Rust conventions and provides a clear separation of concerns for etcd path handling.

lib/runtime/src/component/endpoint.rs (1)

62-65: LGTM! Method naming improves clarity.

The rename from etcd_path(lease_id) to etcd_path_with_lease_id(lease_id) makes the API more explicit and self-documenting.

Also applies to: 130-134

lib/runtime/tests/namespace_etcd_path.rs (1)

8-118: Well-structured integration tests for namespace paths.

The tests comprehensively cover:

  • Path format validation with the "dynamo://" prefix
  • Hierarchical namespace creation and path generation
  • Component paths with the reserved _component_ keyword
  • Multiple namespace branches

Good test coverage for the new functionality.

lib/runtime/src/transports/etcd/path.rs (3)

10-17: Good design choice for reserved keywords.

Using underscore-prefixed keywords (_component_, _endpoint_) effectively prevents conflicts with user-defined names while maintaining readability.


361-615: Excellent test coverage!

The unit tests comprehensively cover:

  • Basic path parsing and formatting
  • Hierarchical namespaces
  • Component and endpoint paths
  • Lease ID handling with hex formatting
  • Reserved keyword validation
  • Edge cases and error conditions

Well done on the thorough testing.


157-160:

Details

✅ Verification successful

Consider handling negative lease IDs consistently.

The current implementation formats lease IDs as hexadecimal, but negative values might not round-trip correctly. Consider either:

  1. Ensuring lease IDs are always positive
  2. Using unsigned formatting ({:x} on the bits representation)
  3. Documenting the expected behavior for negative lease IDs

Also applies to: 230-236


🏁 Script executed:

#!/bin/bash
# Check how lease IDs are generated in the codebase
rg -A 5 "lease_id|lease\.id\(\)" --type rust | grep -E "(create_lease|lease_id.*=|id:.*i64)"

Length of output: 4173


No changes needed for lease ID formatting

Leases from etcd are always non-negative int64, and Rust’s {:x} formatter paired with i64::from_str_radix(_, 16) supports signed hex (including a leading “−”) correctly. The negative‐ID case cannot occur in practice, so no update is required here.

lib/runtime/src/component.rs (2)

468-486: Well-designed hierarchical namespace implementation.

The parent-child relationship and fully qualified name generation are implemented correctly. The use of Arc for parent references prevents ownership issues while maintaining the hierarchy.


188-191: Clean integration with the new EtcdPath abstraction.

The new methods properly utilize the EtcdPath type for type-safe path construction. The distinction between static and dynamic endpoints (with lease IDs) is handled correctly.

Also applies to: 338-370

@ryanolson ryanolson requested a review from alec-flowers June 11, 2025 19:18
@ryanolson ryanolson enabled auto-merge (squash) June 11, 2025 19:26
@alec-flowers
Copy link
Contributor

alec-flowers commented Jun 11, 2025

The current flow of items is:

  1. Create Typed Struct object (Namespace, Component, Endpoint)
  2. From Typed Struct can create EtcdPath object
  3. From EtcdPath Object can create the actual String used for etcd (or in future use this Path object which implements Discovery / various traits)
  4. From an etcd String can create EtcdPath object

Is there any reason to support going from EtcdPath -> Typed Struct (Namespace, Component, Endpoint) ?

One reason is in the original DEP it was written so that a Canoncial Identifier object was created as the first order of buisness, validated, and then you could create Typed Entities. This ensured that all validation logic was inside the Identifier and that Typed Entities were guaranteed to be valid. The only constructor of the Typed Entities was in the Canoncial Identifier object.

For example:

let namespace_desc = Instance::new_namespace("production.api.v1")?;

let drt = DistributedRuntime::new();
let namespace = endpoint_desc.to_namespace(&drt);

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
lib/runtime/src/transports/etcd/path.rs (1)

148-149: ⚠️ Potential issue

with_extra_path unexpectedly discards an existing lease_id (issue re-introduced)

Resetting self.lease_id to None when merely appending extra path segments silently drops information that callers reasonably expect to be preserved.
This was flagged and removed in an earlier commit (see prior discussion) but has resurfaced here.

-        self.lease_id = None;

Unless there is a compelling, documented reason to invalidate the lease whenever extra segments are added, please remove this line (or add explicit docs + unit test for the behaviour).

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1647ced and ad8eb7f.

📒 Files selected for processing (1)
  • lib/runtime/src/transports/etcd/path.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pre-merge-rust (.)
  • GitHub Check: pre-merge-rust (lib/runtime/examples)
  • GitHub Check: pre-merge-rust (lib/bindings/python)
  • GitHub Check: Build and Test - vllm

@alec-flowers
Copy link
Contributor

Question from me. Is the Etcd Path the Canonical representation? Or will we have another? From the DEP we have this idea of an internal dynamo repr and then etcd and when we Debug format we have both printed.

impl std::fmt::Debug for Path {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "Path({} @ {})", self.etcd_path(), self.to_string())
    }
}

@ryanolson ryanolson merged commit 08355da into main Jun 11, 2025
11 checks passed
@ryanolson ryanolson deleted the ryan/move-kv-store branch June 11, 2025 23:47
nealvaidya pushed a commit that referenced this pull request Jun 26, 2025
@coderabbitai coderabbitai bot mentioned this pull request Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants