Repository navigation
Description
Problem
The owner split this out of #868 on 2026-10-08. Checked on release/v0.2.29 at 910b823.
devops devcontainer bootstrap-k8s deploys by default (--deploy/--no-deploy, src/devops_cli/commands/devcontainer.py:1670-1672), and this repository's devcontainer sets DEVOPS_K8S_AUTO_DEPLOY=true (.devcontainer/devcontainer.json:44). #741 (v0.2.26) fixed the argv: _auto_deploy_k8s_stack now runs ["devops", "k8s", "deploy-stack", "--stack", stack] (commands/devcontainer.py:962-978). The call still cannot deploy anything:
- The child never reaches the keyring.
_auto_deploy_k8s_stackcallsrun_subprocesswith its defaultisolate_env=True(core/process.py:357). The env allowlist (DEFAULT_ALLOWED_ENV_VARS,core/process.py:45-96) dropsDBUS_SESSION_BUS_ADDRESSandXDG_RUNTIME_DIR. Measured in the devcontainer, with the parent connected to a session bus:build_subprocess_env()holds neither key, and a Python child started with that env getskeyring.backends.fail.Keyring. deploy-stack runsrequire_keyring_for_push()before it checks the cluster (commands/k8s/stack_lifecycle.py:1032-1037). With the fail backend it stops withno encrypted OS keyring backend is available (found keyring.backends.fail.Keyring) ...(config/settings.py:824), even when the keyring is unlocked. The code already re-allows the bus forghchildren:CONST_GH_LOGIN_ENV_VARS(config/constants.py:1006-1008) and_GH_ENV(k8s/secret_push.py:50, passed at:325). - No
--context. bootstrap-k8s starts Minikube and runsminikube update-context(commands/devcontainer.py:994-1006). deploy-stack, though, gets no--context, so it resolves the configuredk8s.context(resolve_effective_context,commands/k8s/cluster_runtime.py:134-144), and the config reaches the child through theDEVOPS_CLI_prefix the allowlist keeps (core/process.py:97-98). Post-start spawns the bootstrap by default only when that context isminikube(should_autostart_minikube,cluster_runtime.py:110-131), so on that path both agree. A hand-runbootstrap-k8s --stack <stack> --deploy, or post-start withDEVOPS_MINIKUBE_AUTOSTART=true, deploys to whatever context is configured. Post-start step 9 deliberately realigns kubectl to that configured context (_apply_configured_k8s_context,devcontainer.py:1196-1200). Where it is an Argo-managed cluster, a deploy that got past the keyring would push Secrets and write Argo overrides there (_handle_argo_managed_deployment,stack_lifecycle.py:902-922), and Minikube would stay empty. - Post-start spawns the bootstrap before the session bus starts.
_run_post_start_lifecyclespawns it atdevcontainer.py:1148-1161and starts the D-Bus session bus later, at:1191-1194. The keyring is also normally locked until a person unlocks it. Since feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741, a locked keyring stops deploy-stack before it touches the cluster, so an unattended post-start deploy stops at that gate in the normal case.
The failure is easy to miss:
run_subprocess(check=False, quiet=True)captures output by default (core/process.py:352), so deploy-stack's own error never reaches the terminal or/tmp/devops-k8s-bootstrap.log.MESSAGES.devcontainer.auto_deploy_failed(lang/en/messages.py:895-898) gives no exit status and blames a locked keyring, which is not the cause in case 1.test_post_start_autodeploy_k8s_stackandtest_bootstrap_k8s_autodeploy_k8s_stack(tests/test_devcontainer.py:771-821) use the stackobservability, which deploy-stack rejects (VALID_STACKSis infra, llm, logging, devops, all;commands/k8s/networking.py:60-72). Both assert only the mock's success.run_subprocesscatches onlyFileNotFoundError(core/process.py:403). A deploy-stack that outruns the default 1800 s timeout therefore crashes bootstrap-k8s with aTimeoutExpiredtraceback.
This is the third change to the same ten-line function (#741, then #868's original call-site half). Per the stop-and-re-scope rule, the owner decides the direction before more code is added.
Two options:
- A. Keep auto-deploy and make it work. Pass
--contextwith the Minikube contextminikube update-contextwrites. Pass the keyring session env throughrun_subprocess's allowed env. Run deploy-stack uncaptured, with the exit status in the warning. Spawn the bootstrap after the session bus starts, and skip the deploy with the unlock hint while the keyring is locked. - B. Drop auto-deploy. Remove
--deploy/--no-deploy,_auto_deploy_k8s_stack,DEVOPS_K8S_AUTO_DEPLOYandauto_deploy_failedwith no shim. bootstrap-k8s starts Minikube and prints the deploy-stack command, with--stackand--context, to run once the keyring is unlocked.
Acceptance criteria
- The owner's choice between A and B is recorded on this issue before work starts.
- (A)
_auto_deploy_k8s_stackruns deploy-stack with--stack <stack>and--contextset to a Minikube-context constant. It passes the session-bus keys the Secret Service backend reads throughextra_allowed_env. A test withrun_subprocesspatched asserts the exact argv and the allowed keys. Abuild_subprocess_env(extra_allowed_keys=...)test keepsDBUS_SESSION_BUS_ADDRESS. - (A) deploy-stack runs with
capture_output=False. On a non-zero exit, the warning names the stack and the exit status and quotes no deploy-stack text. A test returns exit 2 with the real stderr shape: the Typer usage panel (╭─ Error ─╮ │ Got unexpected extra argument(s) (infra) │ ╰─╯) followed byElapsed: 0.5s. It asserts the warning has the stack andexit 2, and has neitherElapsednor╰. - (A) Post-start spawns the bootstrap after the session bus is up. While the keyring is locked, the deploy step skips with the unlock hint and the exact deploy-stack command instead of reporting a failure. A deploy-stack timeout becomes a warning, not a traceback. Tests double only the process edges.
- (B) bootstrap-k8s and post-start no longer deploy. The deploy option,
_auto_deploy_k8s_stack,DEVOPS_K8S_AUTO_DEPLOY(.devcontainer/devcontainer.json:44) andMESSAGES.devcontainer.auto_deploy_failedare removed with no shim. bootstrap-k8s printsdevops k8s deploy-stack --stack <stack> --context minikube. A test resolves the printed command withresolve_devops_argvand getsNone. - Either way,
test_post_start_autodeploy_k8s_stackandtest_bootstrap_k8s_autodeploy_k8s_stackuse a stack deploy-stack accepts. They assert the argv that ran or the command that was printed, not only a mock's success. - Every test runs offline, with no network, no DNS and no real keyring, kubectl, helm or minikube. Each test call phase stays under 1 s,
--dry-runmakes zero requests, anduv run devops cipasses. - Pending a person (A): in the devcontainer with Minikube running and the keyring unlocked, run
devops devcontainer bootstrap-k8s --stack infra --deploy. deploy-stack'sInstalling ...lines appear, it printsAuto-deployed Kubernetes stack 'infra', andhelm list -A --kube-context minikubelists the infra releases. With the keyring locked, the same command skips the deploy and prints the unlock hint. - Pending a person (B): run
devops devcontainer bootstrap-k8s --stack infra. Minikube starts and nothing is deployed. Rundevops devcontainer unlock-keyring, then the printed command; it deploys the infra stack to Minikube.
Key questions
- Keep post-start auto-deploy (A) or drop it (B)? (proposed) B. Since feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741, deploy-stack needs an unlocked keyring, and a person unlocks it after the container starts, so an unattended deploy at post-start stops at that gate in the normal case. Printing the command costs nothing and removes the env, context and ordering coupling. A keeps a convenience that works only when the keyring happens to be unlocked, and it needs four changes to one call site.
- (A) Which env keys pass through? (proposed) A dedicated constant with the session-bus keys, not a reuse of
CONST_GH_LOGIN_ENV_VARS, which also carriesgh's config directories. - (A or B) Which context? (proposed)
minikube, as a constant: the contextminikube update-contextwrites. The deploy then targets the cluster bootstrap-k8s started, whateverk8s.contextsays (fail closed). - Should bootstrap-k8s reject a stack deploy-stack would reject? (proposed) No. With A, deploy-stack's own
Invalid stack: '<stack>'. Supported stacks: infra, llm, logging, devops, allline appears uncaptured. With B, the printed command fails the same way when run.
Strategic alignment
- This is a P1 defect on a default path. bootstrap-k8s defaults to deploying, and fix(cli): docs check resolves every devops argv in src #868's grooming called a command that never does half its job broken under policy. The deploy step has never succeeded since v0.2.0.
- Owner rules: stop and re-scope rather than patch on patch, fail closed (never deploy to a context other than the one just started), prefer the simple solution, and
--dry-runmakes zero requests. - Related: feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741 (argv fix and keyring gate), fix(cli): docs check resolves every devops argv in src #868 (the docs-check half, which now resolves every
devopsargv in src, including this call's), and fix(k8s): deploy-stack applies the llm gateway policy and narrows its egress #795 and fix(k8s): deploy-stack applies the monitoring namespace perimeter #913 (change what deploy-stack applies, not its options).
Split from #868 by the owner's scope decision of 2026-10-08 (borrow reason: split). Filed directly because local intake could not reach the model gateway; the roadmap service's intake sets Priority, Value and Effort.
Update 2026-10-08: refinement
The code is unchanged since 910b823; the A/B choice is open. (B) also changes the template (templates/devcontainer.json.j2:44), the spawn argv (commands/devcontainer.py:1029-1032), four tests, the help text and docs/DEVCONTAINER_USAGE.md:334.
- (B)
git grepfinds noDEVOPS_K8S_AUTO_DEPLOY,_auto_deploy_k8s_stackor--no-deployoutside task files.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty-bot commentedon Oct 8, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
The primary dev-environment deploy path is non-functional, but a manual 'devops k8s deploy-stack' workaround exists and no data or security is at risk.Every developer using the devcontainer loses the one-command deploy workflow and must manually invoke deploy-stack with the correct context and keyring access.Three separate code paths need fixes (env allowlist for keyring, --context propagation, post-start ordering) plus test corrections, but each is localized and well-identified.dan-petty commentedon Oct 25, 2026
Decision: Option B (drop auto-deploy). bootstrap-k8s and post-start will no longer deploy, removing --deploy/--no-deploy, _auto_deploy_k8s_stack, DEVOPS_K8S_AUTO_DEPLOY, and auto_deploy_failed without shim, and printing devops k8s deploy-stack --stack --context minikube.
fix(cli): drop devcontainer k8s auto-deploy for printed deploy-stack …