Skip to content

Conversation

@biswapanda
Copy link
Contributor

@biswapanda biswapanda commented Aug 11, 2025

Overview:

dynamo namespace scoping for frontend/backend component

closes: DYN-837
closes: DYN-838

  • when DYN_NAMESPACE is not specified, Frontend will discover model backends from all dynamo namespaces.

  • Supports scoping frontend to a specific dynamo_namespace based on one of 2 syntax:

  1. explicit argument ~
python -m dynamo.frontend --namespace <namespace>

# example -
# python -m dynamo.frontend --http-port 9000 --namespace my-namespace
  1. DYN_NAMESPACE env var
    Now operator auto-injects this env var as part of feat: inject DGD id in planner env variables #2460
export DYN_NAMESPACE=<namespace>
python -m dynamo.frontend

# example -
# export DYN_NAMESPACE=my-namespace
# python -m dynamo.frontend --http-port 9000

Summary by CodeRabbit

  • New Features
    • Added a --namespace CLI option to scope model discovery to a specific namespace.
    • Discovery now supports namespace-specific mode; if no namespace is provided, it continues with global discovery.
    • Startup logs now clearly indicate whether static, namespace-scoped, or global discovery is active, improving observability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 11, 2025

Walkthrough

Adds namespace-scoped model discovery. Frontend exposes a --namespace flag and computes endpoint_id accordingly. LLM input HTTP path introduces a namespace-aware watcher using ModelWatcher::watch_namespace_filtered, with logging clarifying global vs namespace discovery. A new watcher method filters events by namespace; existing global discovery remains unchanged.

Changes

Cohort / File(s) Summary of Changes
Frontend CLI and endpoint selection
components/frontend/src/dynamo/frontend/main.py
Added DEFAULT_NAMESPACE; added --namespace CLI flag; async_main chooses endpoint_id based on provided namespace; startup logs for static/global/namespace discovery.
Watcher with namespace filtering
lib/llm/src/discovery/watcher.rs
Added public async method watch_namespace_filtered to process Put/Delete events only for a target namespace; mirrors existing watcher logic with namespace filter and scoped logging.
HTTP input discovery flow
lib/llm/src/entrypoint/input/http.rs
Replaced unconditional global discovery with conditional namespace-aware flow; added run_namespace_watcher helper using ModelWatcher::watch_namespace_filtered; clarified docs and logs; static remote flow unchanged.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Frontend
  participant Discovery

  User->>Frontend: Start with optional --namespace
  Frontend->>Frontend: Compute endpoint_id (namespace.frontend.http or NS.frontend.http)
  Frontend->>Discovery: Initiate discovery (static or dynamic per namespace/global)
Loading
sequenceDiagram
  participant HTTPEntrypoint
  participant Etcd
  participant ModelWatcher

  HTTPEntrypoint->>HTTPEntrypoint: Check local model namespace
  alt Namespace specified and not "NS"
    HTTPEntrypoint->>Etcd: Watch prefix (namespace-targeted)
    HTTPEntrypoint->>ModelWatcher: watch_namespace_filtered(events, target_namespace)
  else Global or "NS"
    HTTPEntrypoint->>Etcd: Watch prefix (global)
    HTTPEntrypoint->>ModelWatcher: watch(events)
  end
  ModelWatcher->>ModelWatcher: Handle Put/Delete (filtered when namespaced)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I twitch my whiskers, names in tow,
A namespace burrow where models grow.
I watch the keys, I filter neat—
Only my warren’s steady beat.
With logs that glow and paths that thread,
I bound through clusters, lightly tread. 🐇✨


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.
  • 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.

Support

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

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: 3

🧹 Nitpick comments (2)
components/frontend/src/dynamo/frontend/main.py (1)

116-121: Consider adding validation for namespace argument

The --namespace argument accepts any string value without validation. Consider adding a validation function to ensure the namespace follows expected naming conventions (e.g., alphanumeric with underscores, no special characters that might cause issues in etcd keys or endpoint IDs).

Example validation function:

def validate_namespace(value):
    """Validate that namespace follows naming conventions."""
    if value and not re.match(r'^[a-zA-Z_][a-zA-Z0-9_]*$', value):
        raise argparse.ArgumentTypeError(
            f"namespace must contain only alphanumeric characters and underscores, got: {value}"
        )
    return value

Then update the argument definition:

     parser.add_argument(
         "--namespace",
-        type=str,
+        type=validate_namespace,
         default=None,
         help="Dynamo namespace for model discovery scoping. If specified, models will only be discovered from this namespace. If not specified, discovers models from all namespaces (global discovery).",
     )
lib/llm/src/discovery/watcher.rs (1)

333-428: Consider refactoring to reduce code duplication

The watch_namespace_filtered method has significant code duplication with the watch method. Consider refactoring to share common logic while maintaining the namespace filtering capability.

One approach would be to have a single internal method that accepts an optional namespace filter:

async fn watch_internal(&self, mut events_rx: Receiver<WatchEvent>, target_namespace: Option<&str>) {
    let debug_msg = match target_namespace {
        Some(ns) => format!("model watcher started for namespace: {}", ns),
        None => "model watcher started".to_string(),
    };
    tracing::debug!("{}", debug_msg);

    while let Some(event) = events_rx.recv().await {
        match event {
            WatchEvent::Put(kv) => {
                // Parse model entry (common logic)
                let model_entry = match serde_json::from_slice::<ModelEntry>(kv.value()) {
                    // ... error handling ...
                };

                // Apply namespace filter if specified
                if let Some(ns) = target_namespace {
                    if model_entry.endpoint.namespace != ns {
                        tracing::trace!(
                            model_namespace = model_entry.endpoint.namespace,
                            target_namespace = ns,
                            model_name = model_entry.name,
                            "Skipping model from different namespace"
                        );
                        continue;
                    }
                }

                // Rest of the common logic...
            }
            // ... Delete handling ...
        }
    }
}

pub async fn watch(&self, events_rx: Receiver<WatchEvent>) {
    self.watch_internal(events_rx, None).await
}

pub async fn watch_namespace_filtered(&self, events_rx: Receiver<WatchEvent>, target_namespace: &str) {
    self.watch_internal(events_rx, Some(target_namespace)).await
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4385473 and 36bbdd4.

📒 Files selected for processing (3)
  • components/frontend/src/dynamo/frontend/main.py (4 hunks)
  • lib/llm/src/discovery/watcher.rs (1 hunks)
  • lib/llm/src/entrypoint/input/http.rs (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
lib/llm/src/entrypoint/input/http.rs (2)
lib/llm/src/http/service/service_v2.rs (4)
  • etcd_client (58-60)
  • model_manager (122-124)
  • new (29-35)
  • spawn (126-129)
lib/llm/src/discovery/watcher.rs (1)
  • new (48-61)
⏰ 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). (2)
  • GitHub Check: pre-merge-rust (lib/bindings/python)
  • GitHub Check: pre-merge-rust (.)
🔇 Additional comments (4)
components/frontend/src/dynamo/frontend/main.py (1)

182-191: LGTM!

The endpoint_id construction logic correctly handles both namespace-scoped and global discovery modes, using "NS" as the sentinel value for global discovery.

lib/llm/src/entrypoint/input/http.rs (3)

41-71: LGTM!

The namespace filtering logic correctly determines whether to use namespace-specific or global discovery based on the endpoint's namespace. The condition properly handles the "NS" sentinel value and empty strings, with clear logging for both modes.


172-172: Good documentation improvement

The added comment clearly indicates that run_watcher performs global discovery across all namespaces.


191-211: Well-implemented namespace watcher function

The run_namespace_watcher function is properly implemented with clear documentation, appropriate logging, and correct delegation to the watch_namespace_filtered method.

@biswapanda biswapanda changed the title (feat) dynamo namespace scoping for frontend component feat: dynamo namespace scoping for frontend component Aug 14, 2025
@github-actions github-actions bot added the feat label Aug 14, 2025
@copy-pr-bot
Copy link

copy-pr-bot bot commented Aug 14, 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.

@biswapanda biswapanda force-pushed the bis/dyn-837-dynamo-namespace-scoping-for-frontend-component branch from 5c94dd5 to ac61df1 Compare August 14, 2025 03:07
@biswapanda biswapanda force-pushed the bis/dyn-837-dynamo-namespace-scoping-for-frontend-component branch 2 times, most recently from 7888ba2 to d6288ca Compare September 3, 2025 06:58
@biswapanda biswapanda force-pushed the bis/dyn-837-dynamo-namespace-scoping-for-frontend-component branch 2 times, most recently from 94f409e to 11fb3ac Compare September 3, 2025 14:37
@grahamking grahamking self-requested a review September 3, 2025 14:42
Signed-off-by: Biswa Panda <[email protected]>
Signed-off-by: Biswa Panda <[email protected]>
Signed-off-by: Biswa Panda <[email protected]>
Signed-off-by: Biswa Panda <[email protected]>
Signed-off-by: Biswa Panda <[email protected]>
@biswapanda biswapanda force-pushed the bis/dyn-837-dynamo-namespace-scoping-for-frontend-component branch from 3ad1136 to a16f27b Compare September 3, 2025 15:14
@biswapanda biswapanda enabled auto-merge (squash) September 3, 2025 15:16
@biswapanda biswapanda merged commit c6becbc into main Sep 3, 2025
11 checks passed
@biswapanda biswapanda deleted the bis/dyn-837-dynamo-namespace-scoping-for-frontend-component branch September 3, 2025 15:47
biswapanda added a commit that referenced this pull request Sep 3, 2025
biswapanda added a commit that referenced this pull request Sep 3, 2025
biswapanda added a commit that referenced this pull request Sep 5, 2025
dillon-cullinan pushed a commit that referenced this pull request Sep 5, 2025
saturley-hall pushed a commit that referenced this pull request Sep 5, 2025
nnshah1 pushed a commit that referenced this pull request Sep 8, 2025
Signed-off-by: Biswa Panda <[email protected]>
Signed-off-by: nnshah1 <[email protected]>
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