Repository navigation
Description
Problem or Motivation
This is part 1 of 2 of #4559 (Phase 1 of the roadmap pipeline split, owner approval of 2026-11-13). Stage runs in the roadmap Service pod. About 19 releases and ConfigMap edits a day restart that pod (Recreate). Since 2026-11-07, 53 of 71 restarts stopped a running stage round. On 2026-11-13 Prometheus showed 3 staged and 8 failed stage items in 24 hours (devops_cli_roadmap_stage_total).
Before the Service can submit stage Jobs (part 2, #4559), the cluster must admit a stage Job, and the stage command must run one item in a Job. This part adds that, with no change to the rows of the Service. A person can then run one stage Job by hand after the release, and the live run measures the GitHub requests of one cold-cache Job before part 2 ships.
Proposed Solution & Architectural Design
Manifests (Argo CD applies them before the image rolls, so the template, the policy and the Role rows land in this pull request):
k8s/devops/cronjob-stage.yaml: suspended CronJobroadmap-stage, in the form ofcronjob-runner.yaml. Imageghcr.io/dan-petty/devops-cli/service(the Image Updater kustomize override sets its digest, as forcronjob.yaml). Containerstage, args["--version"]. ServiceAccountdevops-cli,automountServiceAccountToken: false. NoenvFrom.secretKeyRefof Secretdevops-clifor 3 keys only:DEVOPS_CLI_SERVICE_GITHUB_APP_PRIVATE_KEY,DEVOPS_CLI_AI_API_KEY,DEVOPS_CLI_MCP_STAGE_TOKEN(all 3 exist in the live Secret on 2026-11-13, so no new Secret key is needed before the roll).OTEL_SERVICE_NAME=roadmap-stage,OTEL_RESOURCE_ATTRIBUTES=service.instance.id=roadmap-stage(fix(telemetry): keep one metric stream per workload #4697). Pod labelsapp.kubernetes.io/name: devops-cli-jobandapp.kubernetes.io/component: roadmap-stage.emptyDirhome and/tmp, ConfigMapdevops-cli-config. Requests 250m and 1Gi, limits 1 CPU and 2Gi (the Service pod peaked at 1.46 GiB in 7 days with every row).activeDeadlineSeconds: 10800,backoffLimit: 2,podFailurePolicy:IgnoreonDisruptionTarget,FailJobon exit codesNotIn [75]. Exit 75 is theevictedexit ofattempt_kill.py(fix(roadmap): a named fix-plan run can skip the 6-hour wait #5413), so an eviction or a drain runs the pod again and a real failure does not.k8s/devops/roadmap-service/admissionpolicy.yaml: a branch on the name prefixdevops-cli-stage-. A stage Job may use the Service image,valueFrom.secretKeyRefof the 3 keys of Secretdevops-cliand no othervalueFrom,backoffLimit: 2only with thepodFailurePolicyabove, and the stage resources. A runner Job keeps every current rule (runner image,envFrom,backoffLimit: 0, the size table). A new policy, or a new validation set, admitsDELETEof a Job byroadmap-serviceonly whenoldObjectis a stage Job.k8s/devops/roadmap-service/role.yaml:geton CronJobroadmap-stage,deleteonjobs.k8s/devops/searxng/networkpolicy-client.yamlandsearxng/networkpolicy.yaml: the stage planner has theweb_searchtool, and today no policy lets a Job pod reach SearXNG on TCP 8080. Admit the pods withapp.kubernetes.io/component: roadmap-stage. The MCP server policy already admitsdevops-cli-jobpods.
Code:
src/devops_cli/k8s/cluster_job.py: aSTAGE_TEMPLATE(roadmap-stage, containerstage) andTemplateName.STAGE, sodevops k8s run-job --template stageworks. The stage Job name isRepoRef.unit_name(ServiceRow.STAGE, <plan key>, item)(ADR 0022, at most 63 characters, the same inputs give the same name, so a second create gets 409). The labels areroadmap.devops-cli/owner,roadmap.devops-cli/repo(RepoRef.owner_label,RepoRef.repo_label),roadmap.devops-cli/itemand the component.src/devops_cli/k8s/cluster_job_api.py:ClusterJobs.delete_job(propagationBackground; 404 is no error).devops roadmap stage --job-item <n>: the normal selection narrowed to item n, with every rule (named=False: the rejected-plan rule, the failure wait, the recorded split, the queue limit).--itemstays for a person and keeps its overrides. The two options together are refused. The option reads and writes only item n: its rejection, its orphan and its result.- The Job entry point (the
--job-itempath):network.set_model_call_limit(1)before the first model call;sigterm_raises()around the plan (fix(roadmap): a named fix-plan run can skip the 6-hour wait #5413); aTimeBudgetof the new settingroadmap.stage.time_budget_seconds, cut to the Job deadline that the Service passes as a plain env value, less a margin for one more model run and the publish (tool < step < Job deadline). Exit 0 for a result, 1 for a failure, 75 forevicted, 143 fordeadline. - Check-in: new
StageRecordKeyvaluesstage.job,stage.job_at,stage.job_deadline(the check-out that part 2 writes) andstage.job_result. At its end the Job writesstage.job_resultand clears the check-out marks in one write, only whenstage.jobnames its own Job (plain env valueDEVOPS_CLI_ROADMAP_STAGE_JOB). Anevictedkill keeps the check-out, because the Job controller runs the pod again. Adeadlinekill records the class and checks in. - A pod that runs again in the same Job and finds its own
stage.pendingmark (the check-out names its Job) judges that mark an orphan at once, removes the branch, and plans the item again in the same run. The 3600 s age rule stays for every other mark. - A request budget for the pod: the entry point makes a
RequestBudget(src/devops_cli/server/service.py) with no record and the new settingroadmap.stage.github_requests_per_hour, and installs it withset_request_gate, as the Service does. So every GitHub request of the stage Job counts in a budget (exit check of Phase 1 in feat(roadmap): track the roadmap pipeline split into jobs #5482). The shared budget in Valkey (feat(service): share the GitHub budget and holds in Valkey #4563) replaces it later. ensure_checkoutgets a blobless clone (git clone --filter=blob:none, ADR 0021 section 6) for the Job clone.- The stage Job calls
plan_stageandStageWriter, the code that the Service uses today, and holds no push or rebase code of its own. The shared push and open steps (fix(roadmap): the final push of the implement Job can miss the latest main #4957, refactor(roadmap): one open step for every pull request #5020) replace code insideStageWriterlater, and the Job gets them with no change. - The planner run tool of feat(k8s): manifest and admission policy for planner sandboxed run job #4003 and feat(roadmap): wire sandboxed run tool into stage toolbox and prompt #4098 stays off in a stage Job:
stage_run_allowlist.pyis imported by no module on 2026-11-13, so no wiring exists to turn off. A later item adds a narrow Role for the run Job template.
Tracker #5482, Phase 1: this item is the stage template (this issue) and the Job side of the stage step (folded into #5499 and #4559 part 2), with the stage part of #5498 (the 3 named keys and the repository token of DEVOPS_CLI_SERVICE_GITHUB_APP_TOKEN_REPOSITORY) and of #5497. The Job runs the plan and publish code of today, so it does not wait for #4957, #5020, #5026 or the scaffold step. Those steps change code inside StageWriter later. A kill replans the item until the plan record moves to Valkey (#4564).
Overlap: #4558 (labels of the runner Job in cluster_job.py; this part labels only the stage Job, with the same RepoRef builders), #5440 (settings of roadmap.stage).
Target Subsystem
SDLC, Git & PR Governance (src/devops_cli/roadmap/stage/, src/devops_cli/k8s/cluster_job.py, src/devops_cli/commands/roadmap.py, k8s/devops/).
Existing Tool Considered
Kubernetes Jobs, podFailurePolicy (GA since Kubernetes 1.31; the cluster runs v1.37.2+k3s1), ValidatingAdmissionPolicy (GA since 1.30), the runner Job pattern of #2667 and attempt_kill.py of #5413. No other tool. Cost: about 120,000 tokens and 4 hours to build, about 5,000 tokens a month to keep, about 20,000 tokens to fix.
Acceptance Criteria
Tests first (each fails before the change):
- A gate test reads
k8s/devops/cronjob-stage.yamland finds the Service image, ServiceAccountdevops-cli, no token, the 3 named secret keys and noenvFrom, the resources,activeDeadlineSeconds: 10800,backoffLimit: 2and thepodFailurePolicy. - The CEL test of the admission policy admits the stage Job that
build_jobmakes from the template, and refuses each variant: the runner image,envFrom, a 4th key or another Secret insecretKeyRef, afieldRef, a token mount, another ServiceAccount,backoffLimit: 2with nopodFailurePolicy, a deadline above 14400. It refuses a runner Job withbackoffLimit: 2. It admits theDELETEof a stage Job and refuses theDELETEof a runner Job. - A test reads
role.yamland findsgeton CronJobroadmap-stageanddeleteonjobs. - A network policy test admits a stage Job pod to SearXNG on TCP 8080 and still refuses a runner Job pod.
- A test builds the stage Job: the args go to container
stage, the Job and the pod have the component, owner, repo and item labels, the name has at most 63 characters, and the same item and plan key give the same name. -
--job-itemleaves out an item with a rejected plan and an item in its failure wait, each with the reason of the normal selection.--itemstill overrules them. - With a fake client, the entry point holds one model call slot and starts no second call.
- SIGTERM before the time budget ends exits 75 and keeps the check-out; after the budget exits 143 and records
deadline; a normal end writesstage.job_resultand clears the check-out only whenstage.jobnames the Job. - A pod that runs again with its own
stage.pendingmark and a pushed branch removes the branch and stages the item in the same run. - The entry point installs a request gate whose limit is
roadmap.stage.github_requests_per_hour, and a request past the limit waits. - A structural test finds no direct
git pushorgit rebasecall in the entry point module.
Live proof after the release (real calls against the cluster and GitHub):
-
uv run devops k8s run-job --template stage -- roadmap stage --repo dan-petty/devops-cli --job-item <n> --confirmon a real Ready item opens the draft pull request. Akubectl -n devops rollout restart deploy/roadmap-serviceduring the Job does not stop it. - The GitHub requests of that cold-cache Job (
devops_cli_github_requests_total{job="roadmap-stage"}) are measured and stated in a comment on feat(roadmap): run each stage item in its own Job #4559, against the 3,357 requests a day of the stage row. -
kubectl -n devops get jobs -l app.kubernetes.io/component=roadmap-stage,roadmap.devops-cli/item=<n>lists the Job.
Source: #4559
Activity
dan-petty commentedon Nov 13, 2026
Both target the roadmap pipeline split into Jobs; #5482 tracks the whole split while the candidate delivers only the stage Job template and one-item entry point.devops-cli-service commentedon Nov 13, 2026
Released in v0.132.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.132.0
devops-cli-service commentedon Nov 13, 2026
Live since 2026-11-13 20:55 UTC
feat(roadmap): run each stage item in its own Job