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
Source
Source: #4517
Alternatives check of 2026-11-27: 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-27, maintained.
Reason: Searches found the Argo Workflows engine, which the issue itself names as already in use, and no other tool: it provides WorkflowTemplate, synchronization mutexes and semaphores, retryStrategy expressions and template deadlines that this scope needs.
Covers:
- WorkflowTemplate referenced by a Workflow for one item
- Synchronization mutex and semaphore keys from a ConfigMap
- retryStrategy expression, limit, backoff and factor
- Template activeDeadlineSeconds and pod metadata labels
Lacks:
- Admission policy must be extended to the Argo controller's user
- Service RBAC and submission code for workflows.argoproj.io
- ADR 0022 unit names are project code, not a tool field
- Parameterised mutex and restart behaviour still needs the feat(k8s): let Argo Workflows run roadmap pods in devops #4566 measurement
Proposed design
Problem statement
The stage job runs as a Kubernetes Job from the template of CronJob roadmap-stage. The approved pipeline split puts each job of an item under one item lock. This change moves the stage job to WorkflowTemplate roadmap-stage in namespace devops. The template takes the item lock and the semaphores of ConfigMap roadmap-limits. It retries exit 75 only, sets a deadline, and carries the ADR 0022 unit name and labels. The Service creates one Workflow for one item, and the stage CronJob is removed.
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 absent.
Scenario: The k8s row checks the stage template
- WHEN I run
uv run devops ci --check --only k8s. - THEN It passes, and the stage check of the row reports WorkflowTemplate
roadmap-stagein namespacedevopsand no CronJobroadmap-stage.
Requirement: Retry only exit 75
The roadmap-stage template MUST retry a pod that exits 75 with limit 2, backoff 30 s and factor 2, and MUST NOT retry a pod that exits 1.
Scenario: The k8s row checks the retry strategy
- WHEN I run
uv run devops ci --check --only k8s. - THEN It passes, and the stage check reports a
retryStrategywith limit 2, backoff 30 s, factor 2 and the expressionasInt(lastRetry.exitCode) == 75.
Requirement: One stage Workflow for each item
The roadmap-stage template MUST serialize the stage Workflows of one item under the item lock that #4566 selects.
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 k8s row checks the semaphore key
- WHEN I run
uv run devops ci --check --only k8s. - THEN It passes, and the stage check reports that each semaphore key of
roadmap-stageexists in ConfigMaproadmap-limits.
Requirement: Template deadline
The roadmap-stage template MUST set activeDeadlineSeconds to the value of CONST_ROADMAP_STAGE_JOB_DEADLINE_SECONDS.
Scenario: The k8s row checks the deadline
- WHEN I run
uv run devops ci --check --only k8s. - THEN It passes, and the stage check reports that the
activeDeadlineSecondsofroadmap-stageequalsCONST_ROADMAP_STAGE_JOB_DEADLINE_SECONDS.
Requirement: Stage Workflows carry the ADR 0022 name and labels
Each stage Workflow MUST use the ADR 0022 unit name and MUST carry the ADR 0022 labels in metadata.labels and spec.podMetadata.labels, with the repository annotation.
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 each stage Workflow of that repository and no Workflow of another repository, and each listed Workflow has the ADR 0022 unit name, the ADR 0022 labels in both places and the annotation
roadmap.devops-cli/repository.
Requirement: Pending a person after the merge
ValidatingAdmissionPolicy roadmap-service-jobs MUST apply its stage rules to the pods that roadmap-stage makes.
Scenario: The live proof of the stage policy
- WHEN After the merge, a person submits a stage Workflow for an item, and a stage Workflow whose pod template sets
hostNetwork: true. - THEN The first Workflow makes its pod, and the second Workflow makes no pod and reports an error that names
roadmap-service-jobs.
Requirement: The Service submits a stage Workflow
The Service MUST create a Workflow from WorkflowTemplate roadmap-stage for one item, with the item parameters and the ADR 0022 labels, and MUST NOT create a Job from CronJob roadmap-stage.
Scenario: The stage submission builds a Workflow
- WHEN I run
uv run pytest tests/roadmap/stage -q. - THEN It passes, and a test asserts that a stage submission builds a Workflow with
workflowTemplateRef.nameroadmap-stage, the item parameters and the ADR 0022 labels.
Existing Tool Considered
The alternatives check of 2026-11-27 in the issue body gives Argo Workflows (argoproj/argo-workflows, Apache-2.0, maintained) the verdict in-use, because the repository already uses it. That check records what the tool covers and what it lacks. The proposal fills the gaps that the check lists: it extends ValidatingAdmissionPolicy roadmap-service-jobs to the Argo controller's service account, adds the Service RBAC and the submission code for workflows.argoproj.io, and writes the ADR 0022 unit names as project code. The #4566 measurement selects the item lock before the build starts.
Key questions
- How does the
roadmap-stagetemplate retry a pod that exits 75, and not a pod that exits 1?: The template setsretryStrategywithlimit: 2,backoff: {duration: 30s, factor: 2}andexpression: asInt(lastRetry.exitCode) == 75. Argo retries only the exit codes that the expression names, so a pod that exits 1 ends the Workflow. (best practice) [sources: docs/guidelines/agentic-jobs.md]- Chosen: retryStrategy expression on lastRetry.exitCode. The guideline records the field, and Argo retries only the exit codes that the expression names.
- Rejected: retryStrategy with a limit and no expression. It retries every failed pod, and a pod that exits 1 must not run again.
- Rejected: podFailurePolicy on the exit code. The field belongs to a Kubernetes Job, and a Workflow template has no such field.
- Which
activeDeadlineSecondsdoes theroadmap-stagetemplate set?: The template setsactiveDeadlineSecondstoCONST_ROADMAP_STAGE_JOB_DEADLINE_SECONDS, the value that the stage Job uses today. The stage time budget does not change. (best practice) [sources: src/devops_cli/config/constants.py:4500, k8s/devops/cronjob-stage.yaml, tests/gate/k8s_checks/stage_job.py, docs/guidelines/agentic-jobs.md]- Chosen: CONST_ROADMAP_STAGE_JOB_DEADLINE_SECONDS. It keeps the stage time budget and the check that holds the constant.
- Rejected: A new stage deadline. It changes the stage time budget with no measurement.
- Rejected: No deadline. The guideline asks for a deadline and a retry rule on each unit.
- Which lock keeps two stage Workflows of one item apart?: The template takes the item mutex
item-<repo>-<n>. When the measurement of feat(k8s): let Argo Workflows run roadmap pods in devops #4566 shows that a mutex with a parameter name fails, the template takes the Valkey lease for the item instead. feat(k8s): let Argo Workflows run roadmap pods in devops #4566 is a dependency, so the answer is known before the build. (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, src/devops_cli/roadmap/stage/stage_submit.py]- Chosen: Item mutex, with the feat(k8s): let Argo Workflows run roadmap pods in devops #4566 fallback. ADR 0021 puts a lock on each item, and the mutex needs no new code when feat(k8s): let Argo Workflows run roadmap pods in devops #4566 passes.
- Rejected: One mutex for each repository. Two stage Workflows of one item still run together.
- Rejected: Valkey lease as the first choice. It adds code when the item mutex may work, and feat(k8s): let Argo Workflows run roadmap pods in devops #4566 names it as the fallback.
- Which semaphore of ConfigMap
roadmap-limitsdoes theroadmap-stagetemplate take?: The template takes the semaphore key that the ConfigMap gives to the work that calls a model, because the stage row calls a model. The k8s row asserts that each semaphore key of the template exists in the ConfigMap, so a key that the ConfigMap does not define fails the check. (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]- Chosen: The model-work key of the ConfigMap. The stage row calls a model, and the ConfigMap owns the limit of that work.
- Rejected: No semaphore. The scope and ADR 0021 ask for the semaphores of the ConfigMap.
- Rejected: A new key in the template. A key that the ConfigMap does not define takes no slot, and the limit is lost.
- How does the stage pod keep the admission rules that the stage Job has today?: ValidatingAdmissionPolicy
roadmap-service-jobsalso matches the pods ofroadmap-stage, with the stage rules. ItsmatchConstraintsaddpods, and its match condition names the Argo Workflow controller's service account as well assystem:serviceaccount:devops:roadmap-service. The policy that guards a Job delete also guards a stage Workflow. (best practice) [sources: k8s/devops/roadmap-service/admissionpolicy.yaml, tests/gate/k8s_checks/job_admission_policy.py, docs/CLUSTER.md]- Chosen: Extend the policy to the stage pod. The stage pod keeps the no-token, image and volume rules that the Job has today.
- 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, and rule AW-T6 forbids a weaker control.
- 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 job builder insrc/devops_cli/k8s/cluster_job.py. The new filek8s/devops/workflowtemplate-stage.yamlfollowsk8s/devops/workflowtemplate-rag-ingest.yaml, andk8s/devops/cronjob-stage.yamlis deleted. The Service Role gainscreate,get,list,patchanddeleteonworkflows.argoproj.io. The stage assertions intests/gate/k8s_checks/stage_job.pymove from the CronJob to the WorkflowTemplate. (best practice) [sources: src/devops_cli/roadmap/stage/stage_submit.py, src/devops_cli/k8s/cluster_job.py, k8s/devops/cronjob-stage.yaml, k8s/devops/workflowtemplate-rag-ingest.yaml, tests/gate/k8s_checks/stage_job.py, docs/CLUSTER.md]- 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, but the Service starts it for one item.
- Does ADR 0022 define the unit name and the labels that a 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 formetadata.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/repository. [sources: docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md]
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.
devops-cli-service commentedon Dec 1, 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.