Skip to content

Conversation

@mohammedabdulwahhab
Copy link
Contributor

@mohammedabdulwahhab mohammedabdulwahhab commented Aug 17, 2025

Overview:

Defaults now set for the working dir/command/args of the Frontend component on a DynamoGraphDeployment:

image

Summary by CodeRabbit

  • New Features

    • Frontend now supports environment-driven defaults: DYNAMO_HTTP_PORT (default 8080) and DYNAMO_ROUTER_MODE. Router mode env added to router deployment.
    • Standardized frontend startup defaults with backend-specific working directories applied automatically.
  • Refactor

    • Operator generates pod specs based on backend framework and removes explicit frontend startup commands from manifests, relying on image defaults.
  • Tests

    • Added tests for frontend pod spec (working dir, command/args, env) and planner service account behavior.
  • Chores

    • Removed license header comment from an RBAC manifest.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 17, 2025

Walkthrough

This change removes explicit Frontend startup commands from backend deployment YAMLs, introduces env-driven defaults for frontend CLI flags, and updates the operator to set framework-specific working directories, default frontend command/args, and HTTP port env. It threads BackendFramework through pod-spec generation and adjusts tests to reflect these defaults.

Changes

Cohort / File(s) Summary
Backend YAML: Frontend startup removed/standardized
components/backends/sglang/deploy/agg.yaml, components/backends/vllm/deploy/agg.yaml, components/backends/vllm/deploy/disagg_router.yaml
Removed Frontend workingDir/command/args; vLLM router disagg adds env DYNAMO_ROUTER_MODE=kv. Backend workers unchanged.
Frontend CLI env defaults
components/frontend/src/dynamo/frontend/main.py
http-port defaults from DYNAMO_HTTP_PORT (fallback 8080); router-mode defaults from DYNAMO_ROUTER_MODE (fallback round-robin). Help text updated.
Operator: framework-aware frontend defaults
deploy/cloud/operator/internal/dynamo/component_common.go, .../component_frontend.go, .../graph.go
Added BackendFramework to ComponentContext; GenerateBasePodSpec/generateComponentContext take/pass BackendFramework; frontend container now sets framework-specific WorkingDir, Command ["python3"], Args ["-m","dynamo.frontend"], and env DYNAMO_HTTP_PORT.
Tests updated and added
deploy/cloud/operator/internal/dynamo/graph_test.go
Updated expectations to include DYNAMO_HTTP_PORT; added tests for frontend base pod spec across frameworks and planner service account; note duplicate TestGenerateBasePodSpec_Frontend present.
RBAC header cleanup
deploy/cloud/operator/config/rbac/role.yaml
Removed SPDX header comment only; RBAC rules unchanged.

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant PodSpecGen as GenerateBasePodSpec
  participant FrontendContainer as Frontend Container
  participant FrontendProc as dynamo.frontend

  Operator->>PodSpecGen: GenerateBasePodSpec(BackendFramework)
  PodSpecGen->>FrontendContainer: Set WorkingDir (by framework), Command ["python3"], Args ["-m","dynamo.frontend"], Env DYNAMO_HTTP_PORT
  FrontendContainer->>FrontendProc: Start with image entrypoint/command
  FrontendProc->>FrontendProc: Parse args with defaults from env (DYNAMO_HTTP_PORT, DYNAMO_ROUTER_MODE)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

I thump my paws: new pods arise,
Env winds set the port and skies.
No shell to wrangle, clean and bright—
python -m springs to life just right.
Framework paths, we hop in tune,
Routers kv, we’re humming soon.
Carrots deployed by afternoon! 🥕✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.2.2)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/product/migration-guide for migration instructions

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.

❤️ 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.
    • 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.
  • 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 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/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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 (6)
components/frontend/src/dynamo/frontend/main.py (1)

95-97: Router-mode env default is fine; consider validating env on startup (optional)

An invalid DYNAMO_ROUTER_MODE env defaults to RoundRobin in code paths below. If you prefer strictness, validate the env value and log/warn or error out early.

deploy/cloud/operator/internal/dynamo/component_frontend.go (1)

108-112: Env var added; align readiness probe with DYNAMO_HTTP_PORT (fallback-safe)

You add DYNAMO_HTTP_PORT but the readiness probe still curls ${DYNAMO_PORT}. To avoid drift, use DYNAMO_HTTP_PORT with a fallback to DYNAMO_PORT.

Proposed readiness probe command (outside this hunk):

Command: []string{
    "/bin/sh",
    "-c",
    "curl -s http://localhost:${DYNAMO_HTTP_PORT:-${DYNAMO_PORT}}/health | jq -e \".status == \\\"healthy\\\"\"",
},

This keeps behavior stable while preferring the new env.

deploy/cloud/operator/internal/dynamo/graph_test.go (4)

4309-4313: Avoid a potential panic: guard against empty containers slice

If GenerateBasePodSpec ever regresses and returns an empty Containers list, this will panic. Add a quick guard as done in other tests in this file.

Apply this diff:

-			// Check working directory
+			// Check working directory
+			if len(podSpec.Containers) == 0 {
+				t.Fatalf("GenerateBasePodSpec() returned no containers")
+			}
 			if podSpec.Containers[0].WorkingDir != tt.wantWorkingDir {
 				t.Errorf("GenerateBasePodSpec() workingDir = %v, want %v",
 					podSpec.Containers[0].WorkingDir, tt.wantWorkingDir)
 			}

4315-4322: Make command assertion slightly less brittle across images

Some images may expose “python” vs “python3” as the interpreter. Keeping the args strict but relaxing the interpreter check improves portability without losing intent.

Apply this diff:

-			// Check command and args
-			if !reflect.DeepEqual(podSpec.Containers[0].Command, []string{"python3"}) {
-				t.Errorf("GenerateBasePodSpec() command = %v, want %v",
-					podSpec.Containers[0].Command, []string{"python3"})
-			}
-			if !reflect.DeepEqual(podSpec.Containers[0].Args, []string{"-m", "dynamo.frontend"}) {
-				t.Errorf("GenerateBasePodSpec() args = %v, want %v",
-					podSpec.Containers[0].Args, []string{"-m", "dynamo.frontend"})
-			}
+			// Check command and args
+			if len(podSpec.Containers[0].Command) == 0 || !strings.Contains(podSpec.Containers[0].Command[0], "python") {
+				t.Errorf("GenerateBasePodSpec() command = %v, want interpreter starting with python*",
+					podSpec.Containers[0].Command)
+			}
+			if !reflect.DeepEqual(podSpec.Containers[0].Args, []string{"-m", "dynamo.frontend"}) {
+				t.Errorf("GenerateBasePodSpec() args = %v, want %v",
+					podSpec.Containers[0].Args, []string{"-m", "dynamo.frontend"})
+			}

4226-4337: Optional: add a “noop/unknown” framework case

To lock in the behavior that unknown frameworks don’t set a working dir, consider a negative case (BackendFrameworkNoop or an unknown string) that expects WorkingDir == "" and still uses python3 -m dynamo.frontend.

Happy to draft the additional table entry if you want it included in this PR.


4314-4322: Optional: also assert container name is “main”

Other tests in this file rely on the convention that the primary container is named “main”. Asserting it here would catch regressions earlier.

You can append:

if podSpec.Containers[0].Name != "main" {
	t.Errorf("GenerateBasePodSpec() container name = %s, want main", podSpec.Containers[0].Name)
}
📜 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.

📥 Commits

Reviewing files that changed from the base of the PR and between fb10ffb and f7f6b18.

📒 Files selected for processing (9)
  • components/backends/sglang/deploy/agg.yaml (0 hunks)
  • components/backends/vllm/deploy/agg.yaml (0 hunks)
  • components/backends/vllm/deploy/disagg_router.yaml (1 hunks)
  • components/frontend/src/dynamo/frontend/main.py (1 hunks)
  • deploy/cloud/operator/config/rbac/role.yaml (0 hunks)
  • deploy/cloud/operator/internal/dynamo/component_common.go (1 hunks)
  • deploy/cloud/operator/internal/dynamo/component_frontend.go (2 hunks)
  • deploy/cloud/operator/internal/dynamo/graph.go (2 hunks)
  • deploy/cloud/operator/internal/dynamo/graph_test.go (4 hunks)
💤 Files with no reviewable changes (3)
  • components/backends/sglang/deploy/agg.yaml
  • deploy/cloud/operator/config/rbac/role.yaml
  • components/backends/vllm/deploy/agg.yaml
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-04T13:09:53.416Z
Learnt from: julienmancuso
PR: ai-dynamo/dynamo#1365
File: deploy/cloud/operator/api/v1alpha1/dynamocomponentdeployment_types.go:171-178
Timestamp: 2025-06-04T13:09:53.416Z
Learning: The `DYN_DEPLOYMENT_CONFIG` environment variable (commonconsts.DynamoDeploymentConfigEnvVar) in the Dynamo operator will never be set via ValueFrom (secrets/config maps), only via direct Value assignment. The GetDynamoDeploymentConfig method correctly only checks env.Value for this specific environment variable.

Applied to files:

  • deploy/cloud/operator/internal/dynamo/graph_test.go
🧬 Code Graph Analysis (4)
deploy/cloud/operator/internal/dynamo/component_frontend.go (3)
deploy/cloud/operator/internal/dynamo/component_common.go (1)
  • ComponentContext (41-47)
deploy/cloud/operator/internal/dynamo/graph.go (4)
  • BackendFramework (595-595)
  • BackendFrameworkVLLM (599-599)
  • BackendFrameworkSGLang (598-598)
  • BackendFrameworkTRTLLM (600-600)
deploy/cloud/operator/internal/consts/consts.go (1)
  • DynamoServicePort (11-11)
deploy/cloud/operator/internal/dynamo/component_common.go (1)
deploy/cloud/operator/internal/dynamo/graph.go (1)
  • BackendFramework (595-595)
components/frontend/src/dynamo/frontend/main.py (1)
lib/llm/src/local_model.rs (1)
  • default (61-78)
deploy/cloud/operator/internal/dynamo/graph.go (2)
deploy/cloud/operator/api/v1alpha1/dynamocomponentdeployment_types.go (1)
  • DynamoComponentDeploymentOverridesSpec (56-58)
deploy/cloud/operator/internal/dynamo/component_common.go (1)
  • ComponentContext (41-47)
🪛 GitHub Actions: Pre Merge Validation of (ai-dynamo/dynamo/refs/pull/2484/merge) by mohammedabdulwahhab.
components/frontend/src/dynamo/frontend/main.py

[error] 83-92: Black formatting check failed. The pre-commit hook reformatted 'components/frontend/src/dynamo/frontend/main.py'; please commit the changes or re-run pre-commit to fix formatting.

⏰ 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: pre-merge-rust (lib/bindings/python)
  • GitHub Check: pre-merge-rust (lib/runtime/examples)
  • GitHub Check: pre-merge-rust (.)
  • GitHub Check: Build and Test - dynamo
🔇 Additional comments (9)
deploy/cloud/operator/internal/dynamo/component_common.go (1)

41-47: Struct extension LGTM

Adding BackendFramework to ComponentContext is consistent with downstream usage and enables framework-aware defaults. No issues spotted.

deploy/cloud/operator/internal/dynamo/component_frontend.go (3)

26-37: WorkingDir defaults look good; ensure context passes the graph’s backend

This mapping is correct. Note: it depends on ComponentContext.BackendFramework being the graph’s framework (vllm/sglang/trtllm), not “noop”. See my graph.go comment about ensuring the context uses the graph-level backend for non-worker components.


43-47: WorkingDir assignment LGTM (subject to correct context propagation)

This is correct and harmless when empty. The only caveat is ensuring the context.BackendFramework is set for Frontend components (see graph.go comment).


48-51: Good default: run python3 -m dynamo.frontend

Switching from /bin/sh -c to an explicit python3 command is cleaner and avoids shell quoting issues. User overrides still work via ExtraPodSpec merge.

deploy/cloud/operator/internal/dynamo/graph_test.go (5)

1286-1289: LGTM: Frontend now exports DYNAMO_HTTP_PORT in Pod spec

Adding DYNAMO_HTTP_PORT to the frontend container’s Env aligns tests with the new frontend defaults and makes the port explicit at runtime. Sorting of envs later in the test ensures stability.


2027-2030: LGTM: Multinode SGLang frontend includes DYNAMO_HTTP_PORT

Good expectation update. This keeps the test consistent with the frontend’s env-driven defaults.


2780-2783: LGTM: Multinode VLLM frontend includes DYNAMO_HTTP_PORT

Consistent with the new frontend defaults. Looks good.


4226-4337: LGTM: Solid coverage for frontend defaults (working dir, command/args, env)

Nice table-driven test validating framework-specific working dir, the default python3 -m dynamo.frontend entrypoint, and the DYNAMO_HTTP_PORT env.


4226-4337: ✅ No duplicate TestGenerateBasePodSpec_Frontend found
A repository-wide grep shows only the single declaration in deploy/cloud/operator/internal/dynamo/graph_test.go:4226. There are no naming conflicts that would cause the build to fail.

Copy link
Contributor

@biswapanda biswapanda left a comment

Choose a reason for hiding this comment

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

Lgtm

@mohammedabdulwahhab mohammedabdulwahhab merged commit 28546ba into main Aug 18, 2025
12 of 14 checks passed
@mohammedabdulwahhab mohammedabdulwahhab deleted the mabdulwahhab/frontend branch August 18, 2025 22:19
hhzhang16 pushed a commit that referenced this pull request Aug 27, 2025
Signed-off-by: Hannah Zhang <hannahz@nvidia.com>
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.

4 participants