Unify launch secrets across Kubernetes and Docker - #3473
Draft
morganmcg1 wants to merge 7 commits into
Draft
Conversation
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Credential handling had grown into several unrelated paths: launch-time keys came from shell state,
.env, orgh; W&B used a separately managed cluster Secret; the scout workflow carried literal placeholders; and Docker had no equivalent launch path. That made setup hard to explain, rotation inconsistent, and accidental drift likely.This PR makes the gitignored root
.envthe single operator-facing credential source for every supported launch path.What changed
launch.pyfor Kubernetes and Docker, backed by one shared package-level CLIk8s/launch.pyentrypoint and keeps all launcher Python code undersenpai/launch/.env, secures it to mode0600, and preflights GitHub, Anthropic, Exa, and W&B before launchsenpai.yamlor launch arguments and fails clearly if.envwould override a runtime settingenvFromsenpai-secretsdependency and literal secret template.envand sibling backup files from Git and Docker build contextsSecurity and operations
The operator now copies
example.envto.envand fills in the four required values. Real launches no longer fall back to ambient shell variables orgh auth token; this intentional boundary makes the active credential set visible and reproducible.WANDB_API_KEYis now launch-scoped and preflighted instead of coming from a manually maintained shared Secret.Kubernetes values are sent to
kubectl applythrough stdin. Updating a Secret deliberately does not restart existing pods because that could interrupt long-running training. The launcher warns when a tag already has deployments and prints the explicitkubectl rollout restartcommand to use when interruption is safe. Existing pods keep their current credentials until they restart; new or restarted pods load the updated values.Docker passes values only to the Compose client, which mounts secret files under
/run/secrets; the worker exports them only inside the container because the underlying CLIs require environment variables. Re-running a Docker launch uses--force-recreate, so containers load rotated values.Validation
uv run --with pytest pytest tests/test_launch_credentials.py tests/test_docker_backend.py tests/test_kubernetes_backend.py -q— 12 passeduvx ruff check ...— passedpython -m py_compile ...— passeddocker compose config --quietagainst generated output — passed