Repository navigation
Description
Problem
The refine split of #4566 on 2026-11-14 gives this part its own item. Today the stage job runs as a Kubernetes Job from a CronJob template. The approved pipeline split (tracker #5482) runs each job of an item under one item mutex. #4566 measures two facts on the live controller: does a mutex with a parameter name work, and does a mutex wait survive a controller restart.
Scope
- Move the stage CronJob template to WorkflowTemplate
roadmap-stageindevops. - Use the item mutex
item-<repo>-<n>. If the measurement of feat(k8s): let Argo Workflows run roadmap pods in devops #4566 shows that a mutex with a parameter name fails, use the Valkey lease for each item that its result names. - Use the semaphores of
roadmap-limits. - Add a
retryStrategyfor exit 75: limit 2, backoff 30 s, factor 2. - Add a template-level
activeDeadlineSeconds. - Use the unit names and labels of ADR 0022.
Acceptance criteria
Each as a live check, not a live pytest:
- A pod of
roadmap-stagethat exits 75 is retried. A pod that exits 1 is not. - Two stage Workflows of one item do not run at the same time.
kubectl get workflows -n devops -l roadmap.devops-cli/repo=<name>lists the stage Workflows of that repository.
Dependencies
- chore(roadmap): hold incremental stage and implement work #6521 (hold: incremental stage and implement work)
- feat(k8s): let roadmap-service create Argo Workflows #6592
Source
Source: #4517
Alternatives check of 2026-11-21: in-use.
The repository already uses this tool.
Tool: argoproj/argo-workflows (https://github.com/argoproj/argo-workflows), Apache-2.0, last activity 2026-11-21, maintained.
Reason: Argo Workflows, the engine the project already runs, supplies WorkflowTemplate, exit-code retryStrategy with backoff and factor, template deadlines and mutex/semaphore synchronization; searches returned only weak pages, so parameterised mutex names stay unverified.
Covers:
- WorkflowTemplate holds the stage job spec in devops
- retryStrategy for exit 75, limit 2, backoff 30 s, factor 2
- Template-level activeDeadlineSeconds plus mutex and semaphore synchronization
Lacks:
- Parameterised mutex name per item unverified; feat(k8s): let Argo Workflows run roadmap pods in devops #4566 owns that measurement
- No Valkey lease fallback when the mutex fails
- No unit names or repo label from ADR 0022 generated
- No live check that a wait survives a controller restart
Proposed design
Problem statement
The stage job runs as a Kubernetes Job from a CronJob template. The approved pipeline split runs each job of an item under one item mutex. This item moves the stage job to WorkflowTemplate roadmap-stage in devops, with the item mutex, the semaphores of roadmap-limits, a retry for exit 75, a template deadline, and the unit names and labels of ADR 0022.
Acceptance criteria
Requirement: Stage job runs from a WorkflowTemplate
The stage job MUST run as an Argo Workflow from WorkflowTemplate roadmap-stage in namespace devops, and the stage CronJob MUST be removed.
Scenario: A stage submission creates a Workflow
- WHEN The Service submits a stage job for an item of a repository.
- THEN
kubectl get workflow -n devops -l roadmap.devops-cli/repo=<name> -o jsonpath='{.items[*].spec.workflowTemplateRef.name}'printsroadmap-stage, andkubectl get cronjob -n devops roadmap-stagereturns NotFound.
Requirement: Retry only exit 75
The roadmap-stage template MUST retry a pod that exits 75 with a limit of 2, a backoff of 30 s and a factor of 2, and MUST NOT retry a pod that exits 1.
Scenario: The k8s gate check reads the retry strategy
- WHEN I run
uv run devops ci --check --only k8s. - THEN It passes, and the
k8srow asserts aretryStrategyonroadmap-stagewith limit 2, backoff 30 s, factor 2 and anexpressionthat matches exit code 75 only.
Requirement: One stage Workflow for each item
The roadmap-stage template MUST hold the mutex item-<repo>-<n> of the item of the Workflow.
Scenario: A second stage Workflow of one item waits
- WHEN A stage Workflow of an item runs and I submit a second stage Workflow of the same item.
- THEN
kubectl get pods -n devops -l workflows.argoproj.io/workflow=<second>lists no pod until the first Workflow ends.
Requirement: Semaphore of roadmap-limits
The roadmap-stage template MUST take a semaphore of ConfigMap roadmap-limits in its synchronization block.
Scenario: The template names a limits key
- WHEN I run
uv run devops ci --check --only k8s. - THEN It passes, and the
k8srow asserts that each semaphore ofroadmap-stagenames a key of ConfigMaproadmap-limits.
Requirement: Template deadline
The roadmap-stage template MUST set activeDeadlineSeconds to CONST_ROADMAP_STAGE_JOB_DEADLINE_SECONDS.
Scenario: The deadline keeps the stage limit
- WHEN I run
uv run devops ci --check --only k8s. - THEN It passes, and the
k8srow asserts that theactiveDeadlineSecondsofroadmap-stageequalsCONST_ROADMAP_STAGE_JOB_DEADLINE_SECONDS.
Requirement: Stage Workflows carry the unit name and labels
Each stage Workflow MUST use the ADR 0022 unit name devops-cli-stage-<slug(name)>-<n>-<h10(key, n, input key)> and MUST carry, in metadata.labels and spec.podMetadata.labels, the labels app.kubernetes.io/name: devops-cli-job, app.kubernetes.io/component: roadmap-stage, app.kubernetes.io/part-of: devops-cli-stack, app.kubernetes.io/managed-by: roadmap-service, roadmap.devops-cli/owner, roadmap.devops-cli/repo and roadmap.devops-cli/item, with the annotation roadmap.devops-cli/repository.
Scenario: List the stage Workflows of a repository
- WHEN I run
kubectl get workflows -n devops -l roadmap.devops-cli/repo=<name> -o json. - THEN It lists the stage Workflows of that repository and no Workflow of another repository, and each listed Workflow has the ADR 0022 unit name and labels.
Requirement: Admission policy covers the stage pod
ValidatingAdmissionPolicy roadmap-service-jobs MUST apply its stage rules to the pod that roadmap-stage makes, as it applies them to a stage Job today.
Scenario: The gate check runs the policy against the stage pod
- WHEN I run
uv run devops ci --check --only k8s. - THEN It passes, and the
k8srow shows that a pod ofroadmap-stagewithhostNetworkor a second container is refused.
Existing Tool Considered
Argo Workflows (argoproj/argo-workflows, Apache-2.0, maintained), already in use: the alternatives check of 2026-11-21 returns in-use, and the check's block names what the tool lacks.
Key questions
- How does the
roadmap-stagetemplate retry only exit 75?: The template setsretryStrategywith limit 2, backoff 30 s and factor 2. ItsexpressionmatcheslastRetry.exitCode75 only, so a pod that exits 1 ends the Workflow. The limit of 2 keeps thebackoffLimit: 2of the stage Job. (best practice) [sources: docs/guidelines/agentic-jobs.md:52, docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md:81, docs/CLUSTER.md:85]- Chosen: retryStrategy expression on lastRetry.exitCode. Argo retries only the exit codes that the expression names, and the guideline records the field.
- Rejected: podFailurePolicy on the exit code. The field belongs to a Kubernetes Job. The template has no such field.
- Rejected: Retry every failed pod. It retries exit 1, which is a non-retryable failure of the item.
- Which
activeDeadlineSecondsdoes the template set?: The template setsactiveDeadlineSecondstoCONST_ROADMAP_STAGE_JOB_DEADLINE_SECONDS, the 10800 s of the stage Job today. The stage time budget does not change. (best practice) [sources: docs/CLUSTER.md:85, src/devops_cli/config/constants.py:4129]- Chosen: 10800 s, CONST_ROADMAP_STAGE_JOB_DEADLINE_SECONDS. It keeps the stage time budget and the gate check that holds the constant.
- Rejected: 7200 s, the runner CronJob value. It cuts the stage budget by one hour.
- Rejected: No deadline. ADR 0021 asks for a deadline on each template.
- Which lock keeps two stage Workflows of one item apart?: The template takes the item mutex
item-<repo>-<n>. ADR 0021 requires a mutex for each item. When feat(k8s): let Argo Workflows run roadmap pods in devops #4566 shows that a parameterised mutex name fails, the template takes the Valkey lease for the item instead. This item waits on feat(k8s): let Argo Workflows run roadmap pods in devops #4566, so the result is known at build time. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:63, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:67]- Chosen: Item mutex with a parameterised name. ADR 0021 puts a mutex on each item, and the mutex needs no new code.
- Rejected: One mutex for each repository. Two stage Workflows of one item still run together.
- Rejected: Valkey lease for each item. It is the fallback that feat(k8s): let Argo Workflows run roadmap pods in devops #4566 names, and it adds code.
- Which semaphore of ConfigMap
roadmap-limitsdoes the stage Workflow take?: It takes semaphoreagent, one of the three semaphores that ADR 0021 puts in ConfigMaproadmap-limits. The stage row calls a model, andagentadmits the pods that do model work. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:67, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:97]- Chosen: agent. The stage row calls a model, so it takes the semaphore for model work.
- Rejected: No semaphore. ADR 0021 asks for the semaphores of the ConfigMap.
- Rejected: A new key. ADR 0021 names the three keys of the ConfigMap.
- How does the stage pod keep the admission rules that the Job policy gives it?: ValidatingAdmissionPolicy
roadmap-service-jobsalso matches the pods ofroadmap-stage, with the stage rules. ItsmatchConstraintsaddpods, and its match condition names the Argo Workflow controller's user instead of onlysystem:serviceaccount:devops:roadmap-service; the gate check evaluates the stage pod rules. (best practice) [sources: docs/CLUSTER.md:71, k8s/devops/roadmap-service/admissionpolicy.yaml:39, tests/gate/k8s_checks/job_admission_policy.py]- Chosen: Extend the policy to the stage pod. The stage pod keeps the no-token, image and volume rules.
- Rejected: Keep the stage CronJob. The scope moves the stage job to a WorkflowTemplate.
- Rejected: Drop the rules for the stage pod. The pod loses the guard that the Job has today.
- Which code starts the stage Workflow, and what happens to CronJob
roadmap-stage?:src/devops_cli/roadmap/stage/stage_submit.pycreates a Workflow fromroadmap-stagefor the item, through the stage template insrc/devops_cli/k8s/cluster_job.py, andk8s/devops/cronjob-stage.yamlis deleted. The new template followsk8s/devops/workflowtemplate-rag-ingest.yaml. The Service's Roleroadmap-service-jobsgainscreate,get,list,patchanddeleteonworkflows.argoproj.ioand dropsgeton CronJobroadmap-stage; the delete policy ink8s/devops/roadmap-service/admissionpolicy.yamlgains the same guard for a stage Workflow thatroadmap-service-job-deleteshas for a stage Job. (best practice) [sources: src/devops_cli/roadmap/stage/stage_submit.py, src/devops_cli/k8s/cluster_job.py:74, k8s/devops/cronjob-stage.yaml, k8s/devops/workflowtemplate-rag-ingest.yaml, k8s/devops/roadmap-service/role.yaml:21, k8s/devops/roadmap-service/admissionpolicy.yaml:316]- Chosen: Create a Workflow from the template. The Service starts one stage job for one item, and a Workflow takes the item as a parameter.
- Rejected: Keep the CronJob and add the template. Two paths start the stage job.
- Rejected: A CronWorkflow. A schedule starts the stage job, and the Service starts it for one item.
- Does ADR 0022 define the unit names and labels that the stage Workflow takes?: Yes. ADR 0022 section 2 gives the unit name
devops-cli-stage-<slug(name)>-<n>-<h10(key, n, input key)>of 63 characters or fewer. Section 3 gives the labels that each Workflow carries inmetadata.labelsandspec.podMetadata.labels:app.kubernetes.io/name: devops-cli-job,app.kubernetes.io/component: roadmap-stage,app.kubernetes.io/part-of: devops-cli-stack,app.kubernetes.io/managed-by: roadmap-service,roadmap.devops-cli/owner,roadmap.devops-cli/repoandroadmap.devops-cli/item, with the annotationroadmap.devops-cli/repositoryand the environment variableOTEL_SERVICE_NAME: roadmap-stage. [sources: docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md:57, docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md:69, docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md:71]
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 21, 2026
Both touch the stage job template in devops, but 5483 adds the Kubernetes Job template and the candidate converts that template to a WorkflowTemplate.devops-cli-service commentedon Nov 21, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (10)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 22, 2026
Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.