Repository navigation
Description
Problem or Motivation
The runner Job of implement carries the label implement-repo with a hash value and the name app.kubernetes.io/name: devops-cli-job. A person cannot list the Jobs of one repository or one item with kubectl. The pods carry no repository annotation, so Loki cannot label the logs of a Job pod by repository.
The stage Job and the Workflows of the move need the same labels from the start, so that no later rename is needed. A rename of the selector key has no safe rollout: Image Updater rolls the Service about 15 times a day, runner Jobs run about 6 times a day, and a new Service that lists by a new key does not see a running Job for up to the 4-hour deadline. It could then start a second implement Job for the same repository.
Proposed Solution & Architectural Design
Use the rules of the naming ADR and the builders of RepoRef:
src/devops_cli/k8s/cluster_job.py:build_jobadds the labelsroadmap.devops-cli/owner,roadmap.devops-cli/repo,roadmap.devops-cli/item,app.kubernetes.io/component: roadmap-<row>,app.kubernetes.io/part-of: devops-cli-stack,app.kubernetes.io/managed-by, and the annotationroadmap.devops-cli/repository(the casefoldedkey) on the Job and on the pod template.repository_labelandjob_namemove intoRepoRef(no shim).- The runner Job gets the ad hoc name
devops-cli-implement-<slug>-<item>-<6 hex>. A unit Job gets the unit name. - The label
implement-repokeeps its key and value. It goes away only when no code lists by it (with feat(roadmap): Run implement as Argo Workflow with per-group resubmit #3105). app.kubernetes.io/name: devops-cli-jobdoes not change, so the NetworkPolicies and the admission policy apply as before.k8s/devops/cronjob-runner.yaml:OTEL_SERVICE_NAME=roadmap-implement. Change the two dashboard descriptions that namedevops-cli-job.- Also change
src/devops_cli/roadmap/implement/implement_submit.pyandsrc/devops_cli/commands/k8s/cluster_jobs.py. - Coordinate with feat(roadmap): add the three-container runner Job, policy and log reads #3700 (two-container runner Job), which changes the same template.
Target Subsystem
Kubernetes & Minikube Automation (src/devops_cli/k8s/cluster_job.py, k8s/devops/).
Existing Tool Considered
Kubernetes labels and annotations and kube-state-metrics (it exports all pod labels). No build beyond the label code. Cost: about 250,000 tokens and 2.5 hours to build, about 5,000 tokens a month to keep, about 30,000 tokens to fix.
Acceptance Criteria
- A new runner Job is named
devops-cli-implement-<slug>-<item>-<6 hex>, with 63 characters or fewer. kubectl -n devops get jobs -l roadmap.devops-cli/repo=<name>,roadmap.devops-cli/item=<n>lists it, and its pod carries the same labels and the annotation.- The Service still finds a running Job that an older image made: a test lists a Job with only the old labels.
- The NetworkPolicy and admission policy tests pass.
--dry-runshows the Job name and makes no request.
Dependencies
- "feat(roadmap): name each repository's resources from one RepoRef".
Source: #4517
Proposed design
Problem statement
A runner Job carries only the hashed label implement-repo and the generic name devops-cli-job. A person cannot list the Jobs of one repository or one item with kubectl. Loki cannot label the log stream of a Job pod by repository. The new labels must land before the Service and the Workflows rely on them, because a later rename of the selector key has no safe rollout.
Acceptance criteria
Requirement: Repository and item labels
build_job SHALL set roadmap.devops-cli/owner, roadmap.devops-cli/repo and roadmap.devops-cli/item on the Job metadata and on the pod template metadata.
Scenario: Labels on the Job and on its pod
- WHEN
build_jobbuilds a runner Job for repositoryDan-Petty/DevOps-CLIand item 4558 - THEN both metadata blocks hold
roadmap.devops-cli/owner: dan-petty,roadmap.devops-cli/repo: devops-cliandroadmap.devops-cli/item: 4558.
Requirement: Repository annotation on the pod
build_job SHALL set the annotation roadmap.devops-cli/repository to the casefolded owner/name on the Job and on the pod template.
Scenario: The annotation reaches the pod
- WHEN
build_jobbuilds a Job forDan-Petty/DevOps-CLI - THEN the Job metadata and the pod template metadata hold the annotation
roadmap.devops-cli/repository: dan-petty/devops-cli.
Requirement: Component and ownership labels
build_job SHALL set app.kubernetes.io/component: roadmap-<row>, app.kubernetes.io/part-of: devops-cli-stack and app.kubernetes.io/managed-by: devops-cli on the Job and on the pod template.
Scenario: The component of the runner Job
- WHEN the Service builds a runner Job for the
implementrow - THEN both metadata blocks hold
app.kubernetes.io/component: roadmap-implementandapp.kubernetes.io/part-of: devops-cli-stack.
Requirement: Runner Job name
The runner Job of the Service SHALL be named devops-cli-implement-<slug>-<item>-<6 hex> and MUST hold 63 characters or fewer.
Scenario: A long slug is cut
- WHEN the slug and the item number make the name longer than 63 characters
- THEN the name holds 63 characters, keeps the
-<6 hex>suffix, and matches the DNS-1123 subdomain form.
Requirement: Old repository label stays
The runner Job MUST keep the label implement-repo with its digest value, and the Service MUST keep listing runner Jobs by it.
Scenario: A Job of an older image is found
- WHEN the Service lists the Jobs of a repository and one carries only
implement-repo: <digest> - THEN the round counts that Job as running for the repository and creates no second runner Job.
Requirement: Name label for the policies
Every Service Job MUST keep the label app.kubernetes.io/name: devops-cli-job on the Job and on the pod template.
Scenario: The policies still select the pod
- WHEN the MCP NetworkPolicy tests and the admission policy tests run against a Job built for item 4558
- THEN the tests pass and the pod label set holds
app.kubernetes.io/name: devops-cli-job.
Requirement: Dry run shows the Job
devops k8s run-job --template runner --dry-run MUST show the Job name and the repository labels and MUST send no request.
Scenario: The dry run of a runner Job
- WHEN a person runs the command with
--repo dan-petty/devops-cli -- true - THEN the printed plan holds the Job name placeholder and the
roadmap.devops-cli/*labels, and no kubectl command runs.
Requirement: Runner telemetry service name
The runner CronJob MUST set OTEL_SERVICE_NAME to roadmap-implement, and the two dashboards that name devops-cli-job MUST name roadmap-implement.
Scenario: The runner reports under its own service name
- WHEN the runner CronJob is read from
k8s/devops/cronjob-runner.yaml - THEN its
runnercontainer holdsOTEL_SERVICE_NAMEwith the valueroadmap-implement.
Existing Tool Considered
No alternatives check has run. Kubernetes labels and annotations, with kube-state-metrics, cover the need: kube-state-metrics exports every Job and pod label, so the change needs no exporter of its own. The code to build is the label code in build_job only. The written cost is about 250,000 tokens and 2.5 hours to build, about 5,000 tokens a month to keep, and about 30,000 tokens to fix.
Key questions
- Which value does the label
roadmap.devops-cli/repohold?: The casefolded repository name, asdevops-cli. The annotationroadmap.devops-cli/repositoryholds the casefolded full key, asdan-petty/devops-cli. (best practice) [sources: src/devops_cli/k8s/cluster_job.py]- Rejected: the full
owner/namekey. A Kubernetes label value cannot hold/, so the API refuses the Job. - Chosen: the casefolded repository name. It is a valid label value, a person can read it, and the annotation holds the full key.
- Rejected: the 16-hex digest. A person cannot read the repository from it, which is the problem this item solves.
- Rejected: the full
- Do the new labels and the new annotation go on the pod template as well as on the Job?: Yes.
_labelledalready copies the labels to the Job and to the pod template, and the change gives the pod template the annotation too. (best practice) [sources: src/devops_cli/k8s/cluster_job.py, k8s/devops/mcp-server/networkpolicy-client.yaml]- Rejected: Job metadata only. Loki cannot label the log stream of the pod by repository, which is the need.
- Chosen: Job and pod template. The pod carries the labels and the annotation, so kubectl and Loki both read them.
- Which value does
app.kubernetes.io/managed-byhold?:devops-cli. The tool that creates the Job is the manager, and the value names the tool. (best practice) [sources: k8s/devops/cronjob-runner.yaml]- Chosen:
devops-cli. The recommended label names the tool that manages the object, anddevops-clicreates the Job. - Rejected: the roadmap row. The row names the component, and the component label already holds it.
- Chosen:
- How does the Service find a running Job while the runner image rolls out?: The Service keeps the label
implement-repowith its key and value, and lists by it. The new labels are additive. The old label goes away with feat(roadmap): Run implement as Argo Workflow with per-group resubmit #3105, in one step. (best practice) [sources: src/devops_cli/roadmap/implement/implement_submit.py, src/devops_cli/commands/k8s/cluster_jobs.py]- Rejected: list by the new labels at once. A new Service does not see a Job that an old image made, and starts a second Job for the repository.
- Chosen: keep
implement-repountil feat(roadmap): Run implement as Argo Workflow with per-group resubmit #3105. Both images write the old label, so every round sees every running Job.
- Where do
repository_labelandjob_namelive after this change?: They stay insrc/devops_cli/k8s/cluster_job.pyat this commit, and one label builder calls them. The repository holds noRepoRefnow, so the move intoRepoRefhappens in the issuefeat(roadmap): name each repository's resources from one RepoRef, with no shim and no second copy. (best practice) [sources: src/devops_cli/k8s/cluster_job.py, src/devops_cli/roadmap/implement/implement_submit.py]- Rejected: move the two builders into
RepoRefnow.RepoRefdoes not exist at this commit, so the change would carry a partial class and a second copy. - Chosen: keep the two builders and call them from the new label builder. It changes one place, and the RepoRef issue moves the two functions without a shim.
- Rejected: move the two builders into
- What name does a Job get that is not a runner Job?: A Job of the
devops-clitemplate keeps<cronjob>-<yyyymmdd-hhmmss>-<4 hex>. No repository item identifies such a Job, so it takes no item name. The RepoRef issue gives the unit name. (best practice) [sources: src/devops_cli/k8s/cluster_job.py, src/devops_cli/commands/k8s/cluster_jobs.py]- Chosen: keep the template name and the timestamp. No item and no repository identify such a Job, and no selector lists it.
- Rejected: give every Job the item name. A Job of the
devops-clitemplate serves no repository item.
- How does a name longer than 63 characters keep a valid form?: The builder cuts the slug and keeps the
-<item>-<6 hex>tail. The result holds 63 characters or fewer and stays a DNS-1123 subdomain. (best practice) [sources: src/devops_cli/k8s/cluster_job.py]- Chosen: cut the slug and keep the hex suffix. The tail names the item, and the hex suffix keeps the name unique.
- Rejected: let the API refuse a long name. The Service would create no Job for a repository with a long name.
- Which callers and tests must change with
build_job?: The callers aresrc/devops_cli/commands/k8s/cluster_jobs.py,src/devops_cli/k8s/cluster_job_api.pyandsrc/devops_cli/roadmap/implement/implement_submit.py. The tests aretests/commands/k8s/test_k8s_run_job.py,tests/gate/k8s_checks/job_admission_policy.py,tests/invariants/test_k8s_mcp_server_policies.py,tests/commands/test_ci.pyandtests/invariants/test_architectural_invariants.py. [sources: src/devops_cli/commands/k8s/cluster_jobs.py, src/devops_cli/k8s/cluster_job_api.py, src/devops_cli/roadmap/implement/implement_submit.py, tests/commands/k8s/test_k8s_run_job.py, tests/gate/k8s_checks/job_admission_policy.py, tests/invariants/test_k8s_mcp_server_policies.py, tests/commands/test_ci.py, tests/invariants/test_architectural_invariants.py] - Which policies select a Job pod by its labels?: The MCP NetworkPolicies select the pods with
app.kubernetes.io/name: devops-cli-job. The admission policyroadmap-service-jobsrefusesvalueFromin a Job of the Service. The labelapp.kubernetes.io/name: devops-cli-jobdoes not change. [sources: k8s/devops/mcp-server/networkpolicy.yaml, k8s/devops/mcp-server/networkpolicy-client.yaml, k8s/devops/cronjob-runner.yaml]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-12: none.
Tool: none found.
Owner decision 2026-11-13
The approved pipeline split (tracker #5482) moves this item to Phase 0, because the stall rule (#5495) finds the running units of an item by these labels. Its scope does not change.
- Live proof: after the merge and the release,
kubectl get jobs -lwith the repository and item labels lists the Jobs of one live item that the App started. A comment gives the command and the Job names.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(roadmap)scope of the title gives the scope.It improves operational visibility but blocks no workflow and has no security impact.A person can list and filter Jobs by repository and item, which aids debugging and log correlation.It changes build_job, RepoRef, the cronjob manifest, two other source files, and requires coordination with issue #3700.Both touch the pod labels in cluster_job.py and the devops-cli-job label, but #4355 fixes NetworkPolicy selection while the candidate adds repository and item labels for kubectl listing.devops-cli-service commentedon Nov 11, 2026
Status set to Ready at 5f75d25 (see proposed design in issue body).
devops-cli-service commentedon Nov 12, 2026
Alternatives check: none
Reason: The searches found only tools that read or copy labels that must already exist: kube-state-metrics generates metrics from Kubernetes objects "without modification", Kyverno mutates labels/annotations only from data a Job or pod already carries, and python-slugify only makes the slug fragment of a name. None of them builds the
roadmap.devops-cli/*labels and annotation on the Job and its pod template, the 63-character runner Job name, or the--dry-runoutput, so the change stays in the project's ownbuild_jobcode, whose naming rules ADR 0022 already fixes.Tool: none found
Tools considered:
Searches run:
Sources:
Checked on 2026-11-12. A person decides what this means for the item. The check changes no label and closes no issue.
feat(roadmap): add the stage Job template and one-item entry point (#…
feat(roadmap): run each stage item in its own Job (#5559)
feat(roadmap): label Service Jobs by repository and item
devops-cli-service commentedon Nov 14, 2026
Released in v0.144.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.144.0
devops-cli-service commentedon Nov 14, 2026
Live since 2026-11-14 22:29 UTC