Run managed vLLM Docker with argv - #5475
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR refactors vLLM container launch in ChangesvLLM Docker argv refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
✨ Thanks for the proposed fix addressing the shell-string-based Docker invocation that created a command injection surface in the managed vLLM startup path. This proposes a way to build Docker argv tokens and execute through Docker adapter helpers, moving container cleanup to argv helpers and resolving the Hugging Face cache mount with os.homedir(). |
|
Superseded by #6523, which rebases this two-file security hardening onto current main with a clean verified/DCO-compliant history. Minh Vu's implementation credit is preserved in the PR body and as Co-authored-by on the signed commit. |
<!-- markdownlint-disable MD041 --> ## Summary <!-- 1-3 sentences: what this PR does and why. --> Replace shell-composed managed vLLM Docker startup with validated argument vectors so profile flags and sensitive environment forwarding reach Docker without shell interpolation. This supersedes #5475 with a current-main, DCO-compliant history. Original implementation credit: Minh Vu (`fallintoplace`). ## Changes <!-- Bullet list of key changes. --> - Build the long-lived vLLM container invocation as validated Docker argv and reject empty or NUL-bearing tokens. - Use typed Docker lifecycle adapters for container removal, detached startup, and shutdown instead of composing shell commands. - Keep Hugging Face token values in the subprocess environment while forwarding only the selected variable name to Docker. - Normalize Hugging Face cache mounts and multi-GPU flags as individual argv tokens. - Add adversarial and lifecycle coverage for metacharacter handling, token secrecy, profile flags, and managed startup. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Quality Gates <!-- Check exactly one tests line and one docs line. Check other lines when applicable. Add every requested justification or approval reference. --> - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — justification: Independent documentation review found no command, configuration, default, output contract, or supported workflow change; this hardens the existing managed vLLM launch path. - [x] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [x] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: Independent nine-category security review returned PASS with no blocking findings. - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Verification <!-- Check each applicable item only when supported by the requested evidence. Run targeted tests once per relevant change set and rerun after later edits or hook autofixes that can affect the tested behavior. Do not rerun hook-covered checks. --> - [x] PR description includes the DCO sign-off declaration and every commit appears as `Verified` in GitHub - [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or `npm run check:diff` passed when hooks were skipped or unavailable — diff-scoped prek validation and the normal pre-push CLI type-check passed on the current commit. - [x] Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification: 56 focused CLI tests and 19 profile integration tests passed with one worker (75/75). - [ ] Applicable broad gate passed — `npm test` for broad runtime/test-harness changes; `npm run check` for repo-wide validation/coverage changes — command/result: Broad gates were not run; the CLI build and type-check passed. - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] `npm run docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- <!-- DCO sign-off is required in this PR description, and every commit must appear as Verified in GitHub. Run: git config user.name && git config user.email --> Signed-off-by: Apurv Kumaria <akumaria@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Improved vLLM container startup using structured Docker argv calls, including clearer Hugging Face cache mounting and GPU-related launch flags. * Updated token handling so inference containers receive token keys while token values are supplied via the runner environment. * **Bug Fixes** * Eliminated shell-assembled container run strings to reliably handle special characters and invalid inputs (e.g., empty/NUL tokens). * Improved idempotent cleanup and container stop behavior on startup/readiness failures. * **Tests** * Expanded coverage for vLLM install and run argument validation, including HF token forwarding and rejection of invalid Docker run flags. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Apurv Kumaria <akumaria@nvidia.com> Co-authored-by: Minh Vu <vuhoangminh97@gmail.com> Co-authored-by: cjagwani <cjagwani@nvidia.com>
<!-- markdownlint-disable MD041 --> ## Summary <!-- 1-3 sentences: what this PR does and why. --> Replace shell-composed managed vLLM Docker startup with validated argument vectors so profile flags and sensitive environment forwarding reach Docker without shell interpolation. This supersedes NVIDIA#5475 with a current-main, DCO-compliant history. Original implementation credit: Minh Vu (`fallintoplace`). ## Changes <!-- Bullet list of key changes. --> - Build the long-lived vLLM container invocation as validated Docker argv and reject empty or NUL-bearing tokens. - Use typed Docker lifecycle adapters for container removal, detached startup, and shutdown instead of composing shell commands. - Keep Hugging Face token values in the subprocess environment while forwarding only the selected variable name to Docker. - Normalize Hugging Face cache mounts and multi-GPU flags as individual argv tokens. - Add adversarial and lifecycle coverage for metacharacter handling, token secrecy, profile flags, and managed startup. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Quality Gates <!-- Check exactly one tests line and one docs line. Check other lines when applicable. Add every requested justification or approval reference. --> - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — justification: Independent documentation review found no command, configuration, default, output contract, or supported workflow change; this hardens the existing managed vLLM launch path. - [x] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [x] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: Independent nine-category security review returned PASS with no blocking findings. - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Verification <!-- Check each applicable item only when supported by the requested evidence. Run targeted tests once per relevant change set and rerun after later edits or hook autofixes that can affect the tested behavior. Do not rerun hook-covered checks. --> - [x] PR description includes the DCO sign-off declaration and every commit appears as `Verified` in GitHub - [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or `npm run check:diff` passed when hooks were skipped or unavailable — diff-scoped prek validation and the normal pre-push CLI type-check passed on the current commit. - [x] Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification: 56 focused CLI tests and 19 profile integration tests passed with one worker (75/75). - [ ] Applicable broad gate passed — `npm test` for broad runtime/test-harness changes; `npm run check` for repo-wide validation/coverage changes — command/result: Broad gates were not run; the CLI build and type-check passed. - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] `npm run docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- <!-- DCO sign-off is required in this PR description, and every commit must appear as Verified in GitHub. Run: git config user.name && git config user.email --> Signed-off-by: Apurv Kumaria <akumaria@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Improved vLLM container startup using structured Docker argv calls, including clearer Hugging Face cache mounting and GPU-related launch flags. * Updated token handling so inference containers receive token keys while token values are supplied via the runner environment. * **Bug Fixes** * Eliminated shell-assembled container run strings to reliably handle special characters and invalid inputs (e.g., empty/NUL tokens). * Improved idempotent cleanup and container stop behavior on startup/readiness failures. * **Tests** * Expanded coverage for vLLM install and run argument validation, including HF token forwarding and rejection of invalid Docker run flags. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Apurv Kumaria <akumaria@nvidia.com> Co-authored-by: Minh Vu <vuhoangminh97@gmail.com> Co-authored-by: cjagwani <cjagwani@nvidia.com>
Summary
The managed vLLM startup path built
docker runas one shell string by joining profile flags, Hugging Face token flags, image/container fields, and the cache mount before executing throughbash -c. That made profile-controlled values and host paths more fragile than they needed to be, and created an avoidable host-side command injection surface.This changes the long-lived vLLM container startup to build Docker argv tokens and execute through the existing Docker adapter helpers. It also moves container cleanup from shell strings to Docker argv helpers, resolves the Hugging Face cache mount with
os.homedir(), and removes the Station multi-GPU shell quote workaround now that--gpus device=0,1is passed as a single argv token.The in-container
/bin/bash -lcboundary remains intentional for the existingpip install ... && vllm serve ...behavior; the host Docker invocation no longer depends on shell parsing.Validation
npm test -- src/lib/inference/vllm.test.ts src/lib/inference/vllm-models.test.tsnpm test -- test/detect-vllm-profile.test.tsnpm test -- src/lib/inference/vllm.test.tsnpx @biomejs/biome lint src/lib/inference/vllm.ts src/lib/inference/vllm.test.tsnpm run build:clinpm run typecheck:cliSummary by CodeRabbit