fix(worker-llm-credentials): write worker-token 0644 so pylon can read it#426
Conversation
📝 WalkthroughWalkthroughThe worker now persists refreshed tokens with ChangesWorker token permissions
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/compute-plane-services/worker-llm-credentials/internal/worker/worker.go`:
- Around line 101-105: Ensure the token refresh flow explicitly applies mode
0644 to the temporary file with os.Chmod after os.WriteFile and before
os.Rename, including when the temporary file already exists. Handle Chmod errors
consistently with the existing write/rename errors, and add tests covering
restrictive umasks and pre-existing temporary files.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 89a0c411-9f39-4f4a-a441-cd6be37ef6af
📒 Files selected for processing (2)
src/compute-plane-services/worker-llm-credentials/internal/worker/worker.gosrc/compute-plane-services/worker-llm-credentials/internal/worker/worker_coverage_test.go
…d it Pylon (llm-router-client) reads /var/run/llm/worker-token to authenticate its router registration, but it runs as a different non-root UID than the credential-manager (root) on the shared emptyDir, so it could not read the 0600 token. Registration failed and gateway invokes returned no_eligible_candidates. Write the token 0644 and chmod the tmp file to force the mode: os.WriteFile honors umask and skips the mode when tmp already exists, so a restrictive container umask or a stale tmp could otherwise leave it 0600. The llm emptyDir is mounted only by the two infra sidecars, not the customer workload container. NO-REF
4e12b4c to
04616dc
Compare
|
🎉 This PR is included in version nvcf-worker-llm-credentials-v1.0.6 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Why
Managed LLM workers never register with the request router, so gateway invokes return
no_eligible_candidates. The credential-manager writes/var/run/llm/worker-tokenas 0600 (owner root), but pylon (llm-router-client) reads it via--auth-token-filewhile running as a different non-root UID (nvs) on the shared emptyDir, so it gets EACCES and never authenticates its registration.What changed
Write the worker-token 0644 so the pylon sidecar can read it. The
llmemptyDir is mounted only by the two infra sidecars (llm-router-client+llm-credential-manager), not the customer workload container, so this does not expose the token to customer code.Security note: this makes a router-auth token world-readable within the pod (gosec G306, suppressed with a reason). The alternative is a matched
runAsUser+ 0600 rendered by icms-translate (#409); this PR is the simpler, credential-manager-local fix. Pick one.Customer Release Notes
LLM function workers now register with the request router in managed deployments; OpenAI-compatible invocations no longer fail with no_eligible_candidates due to the worker-token permission mismatch.
Testing
go test ./internal/worker/(TestRun_CreatesMissingTokenDirnow asserts the token file is written 0644).References
Closes #410
Summary by CodeRabbit
Bug Fixes
0644permissions so required supporting processes can read the shared token file.Tests
0644.