Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/CLUSTER.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ The implement job runs tests, `ruff`, `mypy` and OpenSpec, which the Service ima

The stage job of one item runs in a Job of its own (#5483, part 1 of #4559), so a rollout of the Service does not stop a plan. `devops roadmap stage --repo <owner/name> --job-item <n> --confirm` is the entry point of the Job: it keeps every rule of a round (a rejected plan, the wait of a failure class, a recorded split and the queue limit), and plans and writes item `n` alone, with `plan_stage` and `StageWriter`, the code of the Service. The Job has no git write of its own. The row `stage` of the Service makes one for each Ready item (Roadmap service, step 15, #4559). A person makes one with `devops k8s run-job --template stage --repo <owner/name> --item <n> -- roadmap stage --repo <owner/name> --job-item <n> --confirm`, which refuses the Job while another stage Job of the item has not ended.

- **Template.** Suspended CronJob `roadmap-stage` (`k8s/devops/cronjob-stage.yaml`) runs the runner image `ghcr.io/dan-petty/devops-cli/runner` in container `stage` (#6417), as the implement, fix-checks and planner run Jobs do, with ServiceAccount `devops-cli` and no token, 250m CPU and 1 Gi requested, 1 CPU and 2 Gi at most (the Service pod, which ran every row, peaked at 1.46 GiB in 7 days), an `emptyDir` home of 4 Gi and `/tmp` of 1 Gi, and ConfigMap `devops-cli-config`. It takes 2 keys of Secret `devops-cli` through `secretKeyRef`, each in the variable of its name, and no `envFrom`: `DEVOPS_CLI_SERVICE_GITHUB_APP_PRIVATE_KEY` and `DEVOPS_CLI_AI_API_KEY` (`CONST_ROADMAP_STAGE_JOB_SECRET_KEYS`). It has no MCP token: the MCP client of the stage job is off (`roadmap.stage.mcp`), and the MCP server accepts one token for every role, so the change that turns the client on adds the key. Its telemetry has the `job` `roadmap-stage` (`OTEL_SERVICE_NAME`, `service.instance.id`). The instance id is the same for every stage pod, which holds while one stage pod sends at a time. The pod has 120 s after a SIGTERM to check in (`terminationGracePeriodSeconds`). Image Updater sets the digest of the runner image in it, as in CronJob `devops-cli-runner`. The Job runs no bootstrap of its checkout: it starts the `git`, `gh` and `openspec` of the image (`RUNNER_TOOLS`).
- **Template.** Suspended CronJob `roadmap-stage` (`k8s/devops/cronjob-stage.yaml`) runs the runner image `ghcr.io/dan-petty/devops-cli/runner` in container `stage` (#6417), as the implement, fix-checks and planner run Jobs do, with ServiceAccount `devops-cli` and no token, 250m CPU and 1 Gi requested, 1 CPU and 2 Gi at most (the Service pod, which ran every row, peaked at 1.46 GiB in 7 days), an `emptyDir` home of 4 Gi and `/tmp` of 1 Gi, and ConfigMap `devops-cli-config`. It takes 2 keys of Secret `devops-cli` through `secretKeyRef`, each in the variable of its name, and no `envFrom`: `DEVOPS_CLI_SERVICE_GITHUB_APP_PRIVATE_KEY` and `DEVOPS_CLI_AI_API_KEY` (`CONST_ROADMAP_STAGE_JOB_SECRET_KEYS`). It has no MCP token: the MCP client of the stage job is off (`roadmap.stage.mcp`), and the MCP server accepts one token for every role, so the change that turns the client on adds the key. Its telemetry has the `job` `roadmap-stage` (`OTEL_SERVICE_NAME`, `service.instance.id`). CronJob `roadmap-stage` sets a default `service.instance.id=roadmap-stage`, and `stage_job_env` sets `service.instance.id=<job-name>` as a plain value on each stage Job the Service creates so concurrent pods write separate metric streams (#6364). The pod has 120 s after a SIGTERM to check in (`terminationGracePeriodSeconds`). Image Updater sets the digest of the runner image in it, as in CronJob `devops-cli-runner`. The Job runs no bootstrap of its checkout: it starts the `git`, `gh` and `openspec` of the image (`RUNNER_TOOLS`).
- **Name and labels.** The Service names a stage Job `RepoRef.unit_name(stage, <plan key>, n)`, so the same item and plan input give the same name and a second create gets 409. A Job that a person starts gets `RepoRef.adhoc_name`. Both names start with `devops-cli-stage-`. The Job and its pod carry `app.kubernetes.io/component: roadmap-stage`, `roadmap.devops-cli/owner`, `roadmap.devops-cli/repo` and `roadmap.devops-cli/item` (ADR 0022). The environment names the Job (`roadmap.stage.job`), the time at which its deadline ends (`roadmap.stage.job_deadline`), and the one repository of its GitHub token (`service.github_app.token_repository`). A Job that acts as the GitHub App refuses to run, before a clone or a model call, unless that repository is the repository of `--repo`, as the implement runner does (#2667). A person who runs the command with their own token runs it locally.
- **Retries.** `activeDeadlineSeconds: 10800` (`CONST_ROADMAP_STAGE_JOB_DEADLINE_SECONDS`, a gate check holds both) and `backoffLimit: 2`, with a `podFailurePolicy` that ignores a pod with the condition `DisruptionTarget` and fails the Job on each exit code but 75. The first SIGTERM is a kill with a class (`src/devops_cli/roadmap/attempt_kill.py`): before the time budget ends, it is `evicted`, the command exits 75, and the Job controller runs the pod again; after it, it is `deadline` and the command exits 143. A result exits 0, a retryable failure (such as a provider timeout or clone error) exits 75 and keeps the check-out and claim, and a non-retryable failure of the item exits 1.
- **Budgets.** The pod holds one model call slot. It counts each GitHub request in a budget of its own, `roadmap.stage.github_requests_per_hour` (default 1000) in any one hour, and a request that the hour has no room for waits. The plan has the time budget `roadmap.stage.time_budget_seconds` (default 9000, at most 9000), cut to the deadline of the Job less 1800 s for one more model run and the publish, and above `roadmap.mcp.timeout_seconds`: a tool call ends before the plan, and the plan ends before the deadline. A pod that runs again gets the time that is left. A budget that ends before a model call ends the Job as `deadline`. The command prints the GitHub requests of the pod at its end.
- **Check-out and check-in.** Before the Service creates a stage Job, it writes `stage.job`, `stage.job_at` and `stage.job_deadline` on the item (part 2, #4559). At its end the Job writes `stage.job_result` (the Job, its result and the time, as JSON) and clears these three marks in one write, only when `stage.job` names this Job. Then it writes the result line of its item to stderr, only when that check-in found its check-out, or when no check-out named the Job at its start, as for a Job that a person starts, so each attempt has one line in Loki ([job success](roadmap/job-success.md), #5556). A `deadline` end also records the failure with the class `timeout`, and the item waits as for any failure. An `evicted` end keeps the check-out. The pod that runs again in the same Job removes the branch that the intent mark `stage.pending` names at once, with no wait for the age of the mark, and plans the item again in the same run. A removal or a rejection of a plan keeps these four keys.
- **Submit and recovery.** The row `stage` lists the stage Jobs of every repository by the component label and takes the Jobs of its repository by the owner and repository labels: the Job list is the lock, and an item that a running Job works on stays out of the selection (reason `stage_job`). `roadmap.stage.jobs` (default 1) is the most stage Jobs that run at once in the cluster, for every repository together, because each Job holds a model call slot of the one model tier. For each item that the selection takes, the row writes the check-out with the claim `owner/service` first, then creates the Job from CronJob `roadmap-stage`, named from the item and the hash of its body (`src/devops_cli/roadmap/stage/stage_submit.py`). A create that gets 409 finds the Job of the same item and body, and the check-out names it. An ended Job of the same name is deleted first, so a failed item gets its next Job only after the wait of its failure class. A create that fails takes the check-out and the claim back. Each round compares each check-out with the Job list and checks in for a Job that ended with no check-in: `evicted` when the Job is gone (the item is due at once, free 3 times on one body in `stage.evictions`, then a `ci_infra` failure), `deadline` when the Job failed with `DeadlineExceeded` or still runs 600 s after the deadline of the check-out (the row deletes it; class `timeout` when its pod has a log, `ci_infra` when the pod never ran), `failed` when its pod failure policy or its backoff limit failed it (the class comes from the exit code in the message of the condition and the tail of the log), and `succeeded` when the check-in was lost or the item holds its draft (no failure). The record is text that the author of the issue can edit, so the row acts on a Job only when the item label of the Job names the item of the check-out, and `check_in` reads the item again, so a Job that checked in after the round read its items is no recovery. Recovery runs only when the row runs (`roadmap.stage.interval_minutes`, or a label event of the item), until the general poll of #5524. The item that the row frees has its orphan judged at once, and the removal keeps the failure marks, the count and `stage.evictions`. Only an end with the class `timeout` or `plan_defect` counts with the refused plans toward `roadmap.stage.plan_defect_limit` on one body: the end that reaches the limit returns the item to New with a comment that asks refine to split it, and starts no other Job. An outage of the provider, of GitHub or of the cluster gets the failure marks and the wait of its class only. The row counts each Job in `devops_cli_service_stage_jobs_total` by `repo`, `result` (`created`, `existed`, `evicted`, `deadline`, `failed` or `succeeded`) and `class` (the failure class, or `none`). A stage Job keeps its plan file in the `emptyDir` of its pod, so a pod or a Job that runs again plans its item again, until #5499 makes the branch the checkpoint.
- **Submit and recovery.** The row `stage` lists the stage Jobs of every repository by the component label and takes the Jobs of its repository by the owner and repository labels: the Job list is the lock, and an item that a running Job works on stays out of the selection (reason `stage_job`). `roadmap.stage.jobs` (default 1) is the most stage Jobs that run at once in the cluster, for every repository together: each Job gets its own `service.instance.id` series and request budget, and the 2026-11-19 owner decision keeps the default at 1 until #6319 and #4563 (#6364). For each item that the selection takes, the row writes the check-out with the claim `owner/service` first, then creates the Job from CronJob `roadmap-stage`, named from the item and the hash of its body (`src/devops_cli/roadmap/stage/stage_submit.py`). A create that gets 409 finds the Job of the same item and body, and the check-out names it. An ended Job of the same name is deleted first, so a failed item gets its next Job only after the wait of its failure class. A create that fails takes the check-out and the claim back. Each round compares each check-out with the Job list and checks in for a Job that ended with no check-in: `evicted` when the Job is gone (the item is due at once, free 3 times on one body in `stage.evictions`, then a `ci_infra` failure), `deadline` when the Job failed with `DeadlineExceeded` or still runs 600 s after the deadline of the check-out (the row deletes it; class `timeout` when its pod has a log, `ci_infra` when the pod never ran), `failed` when its pod failure policy or its backoff limit failed it (the class comes from the exit code in the message of the condition and the tail of the log), and `succeeded` when the check-in was lost or the item holds its draft (no failure). The record is text that the author of the issue can edit, so the row acts on a Job only when the item label of the Job names the item of the check-out, and `check_in` reads the item again, so a Job that checked in after the round read its items is no recovery. Recovery runs only when the row runs (`roadmap.stage.interval_minutes`, or a label event of the item), until the general poll of #5524. The item that the row frees has its orphan judged at once, and the removal keeps the failure marks, the count and `stage.evictions`. Only an end with the class `timeout` or `plan_defect` counts with the refused plans toward `roadmap.stage.plan_defect_limit` on one body: the end that reaches the limit returns the item to New with a comment that asks refine to split it, and starts no other Job. An outage of the provider, of GitHub or of the cluster gets the failure marks and the wait of its class only. The row counts each Job in `devops_cli_service_stage_jobs_total` by `repo`, `result` (`created`, `existed`, `evicted`, `deadline`, `failed` or `succeeded`) and `class` (the failure class, or `none`). A stage Job keeps its plan file in the `emptyDir` of its pod, so a pod or a Job that runs again plans its item again, until #5499 makes the branch the checkpoint.
- **Clone.** The Job clones with `--filter=blob:none` (ADR 0021 section 6). The checkout of the default branch fetches the blobs of the staged commit in one batch.
- **Admission policy.** For a stage Job, the policy `roadmap-service-jobs` admits the runner image (alone or with a tag or a digest), as for every Job of the Service, and refuses the Service image. It admits the 2 keys of Secret `devops-cli` in `secretKeyRef` and no other `valueFrom` (no `fieldRef`, no `configMapKeyRef`), no `envFrom`, the args `roadmap stage --repo <owner/name> --job-item <n> --confirm`, only the plain environment names of the template and of `stage_job_env` with `DEVOPS_CLI_SERVICE_GITHUB_APP_TOKEN_REPOSITORY` equal to the repository of `--repo`, `backoffLimit: 2` only with the `podFailurePolicy` above, `activeDeadlineSeconds: 10800` exactly, the resources of the template, and the pod label `app.kubernetes.io/component: roadmap-stage`. A `devops k8s run-job` of a person is not evaluated. Every other rule of a runner Job applies. ValidatingAdmissionPolicy `roadmap-service-job-deletes` admits the `DELETE` of a Job by the Service only when the Job is a stage Job (its name starts with `devops-cli-stage-` and it has the component `roadmap-stage`) or a waiting fix-checks Job (its name starts with `devops-cli-fix-checks-`, it has the component `roadmap-fix-checks`, and `spec.suspend` is true). It refuses the `DELETE` of a runner Job that runs.
- **Network.** The pod keeps the egress of `devops-default-perimeter-egress`, and the MCP server admits it as a `devops-cli-job` pod. The planner has the tool `search_web`, so `searxng-stage-clients` and `searxng-perimeter-ingress` admit the pod with the label `app.kubernetes.io/component: roadmap-stage` to SearXNG on TCP 8080. A runner Job pod cannot reach SearXNG.
Expand Down
2 changes: 1 addition & 1 deletion docs/ENV_VARS.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions k8s/devops/cronjob-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,10 @@ spec:
# The telemetry of a stage Job has the `job` roadmap-stage in Prometheus (ADR 0022).
- name: OTEL_SERVICE_NAME
value: roadmap-stage
# Every stage pod sends this one instance, so its metric stream continues across
# the Job pods instead of starting again at zero in the same Prometheus series
# (#4697). This holds while one stage pod sends at a time
# (`roadmap.stage.jobs` = 1). Two pods at once write one series, and Prometheus
# reads a reset; a limit over 1 needs an instance id for each Job.
# Default instance id for pods started directly from this template (#4697).
# Jobs created by the Service override OTEL_RESOURCE_ATTRIBUTES in
# stage_job_env with service.instance.id=<job-name> so concurrent pods write
# separate series (#6364).
- name: OTEL_RESOURCE_ATTRIBUTES
value: service.instance.id=roadmap-stage
# The spans and the log records name the cluster and the namespace from these two
Expand Down
Loading