Repository navigation
Description
Problem or Motivation
After #5129, a pull request of an infra repo gets a plan, but a merged pull request still waits for a person or an agent to run devops infra apply on a workstation. The cluster is GitOps (Argo CD applies a merged manifest); the hosts under it are not.
Proposed Solution & Architectural Design
Phase 3 of tracker #5120 (design section 8). A step job infra-apply runs when a pull request of an infra repo merges, for a repo at level safe or full. It plans the merge commit, applies it with all guards of #5125, and posts the result and the audit record as a comment on the merged pull request. A cluster Job never drains or reboots its own node or the control-plane node: the job stops before that host and says that the host needs a workstation run. A failure stops the run, leaves the node cordoned and opens or updates one issue in the infra repo.
Target Subsystem
Kubernetes & Minikube Automation
Existing Tool Considered
The webhook router and step jobs of ADR 0021, and devops infra apply. Cost: about 4M tokens to build, 0.5M a quarter to keep, 6 hours.
Acceptance Criteria
- Tests: the job refuses a repo below
safe; it skips its own node and the control-plane node with a clear message; it posts one comment per merge. - Live: a small, non-disruptive dan-petty/homelab pull request merges and the job applies it; the comment holds the audit record.
Dependencies
Proposed design
Problem statement
A merged pull request of an infra repo still needs a person or an agent to run devops infra apply on a workstation. Argo CD applies the merged manifests, but it does not apply the hosts under them. This change adds a step job. The job plans the merge commit and applies the plan with the existing guards. It posts one comment with the result and the audit record. It stops before a host that the job must not drain.
Acceptance criteria
Requirement: Level gate for infra apply
The infra-apply step job SHALL refuse an infra repo whose agent access level is below safe.
Scenario: Refuse plan level
- WHEN a merged pull request of an infra repo at level
noneorplanstarts the step job - THEN the job writes no plan, makes no apply, and reports that the level is too low.
Requirement: Plan before apply
The infra-apply step job SHALL save an infra plan for the merge commit before it applies that plan.
Scenario: Plan the merge commit
- WHEN the step job starts for a merged pull request at level
safeorfull - THEN the job saves the plan for the merge commit and calls
devops infra applyonly with that plan.
Requirement: Apply only an ok plan
The infra-apply step job SHALL apply only an infra plan that ended ok.
Scenario: Failed plan
- WHEN the plan for the merge commit ended
failed - THEN the job makes no apply and reports the failed plan.
Requirement: Apply guards
The infra-apply step job SHALL apply the saved plan through the devops infra apply path that enforces the guards of #5125.
Scenario: Use the existing apply path
- WHEN the step job applies the saved plan
- THEN it calls the same apply function as
devops infra apply, including the drain check, fresh check, health checks and audit record.
Requirement: Stop before own node and control-plane node
The infra-apply step job SHALL stop before a disruptive host that is its pod node or the control-plane node and report a workstation run.
Scenario: Own node in the plan
- WHEN the plan has a disruptive host that is the node of the step job pod or the control-plane node
- THEN the job stops before that host, uncordons no node, and posts a message that names the host and the workstation run.
Requirement: One comment per merge
The infra-apply step job SHALL post exactly one comment on the merged pull request for each merge commit.
Scenario: Second run posts no second comment
- WHEN the step job runs again for the same merged pull request
- THEN it finds the hidden marker and posts no second comment.
Requirement: Audit record in comment
The infra-apply step job SHALL post the infra.apply audit record in the comment on the merged pull request.
Scenario: Comment holds audit record
- WHEN the step job ends an apply
- THEN the comment holds the result and the
infra.applyaudit record.
Requirement: Failure issue and cordon
The infra-apply step job SHALL stop on an apply failure, leave the node cordoned, and open or update exactly one issue in the infra repo.
Scenario: Apply failure on a disruptive host
- WHEN the apply fails on a disruptive host
- THEN the job stops, calls no uncordon for that node, and opens or updates one issue in the infra repo with the failure.
Existing Tool Considered
No alternatives check has run. The plan uses the project's own webhook router and step jobs of ADR 0021 and devops infra apply. It adds no external tool. The body gives the cost: about 4M tokens to build, 0.5M a quarter to keep, 6 hours.
Key questions
- How does a merged pull request of an infra repo start the
infra-applystep job?: The webhook router sets a due mark for the merged pull request. The sweep creates theinfra-applystep job from that due mark. (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, CONTEXT.md]- Chosen: Webhook router and sweep. ADR 0021 makes the webhook router set a due mark and the sweep create the step job.
- Rejected: GitHub Actions workflow in the infra repo. The workflow would need the cluster credentials and would bypass the router.
- Rejected: Polling only. The sweep reconciles, but polling alone delays the job and ignores the webhook.
- Which agent access levels allow the
infra-applystep job to apply a merge commit?: Onlysafeandfullallow an apply. The job refusesnoneandplan. (best practice) [sources: CONTEXT.md]- Chosen: safe and full. An apply changes hosts, and
noneandplando not permit that change. - Rejected: plan and above.
planpermits a plan only, so the job must not apply at that level. - Rejected: all levels.
nonepermits no agent access, so an apply would break the level.
- Chosen: safe and full. An apply changes hosts, and
- Which apply path does the
infra-applystep job use?: The job saves an infra plan for the merge commit and callsdevops infra applyon that plan. The existing apply path holds the drain check, fresh check, health checks andinfra.applyaudit record. (best practice) [sources: CONTEXT.md, tests/commands/test_infra_apply.py, tests/infra/test_plan.py]- Chosen: Call
devops infra apply. The existing command holds the guards and writes the audit record. - Rejected: Reimplement apply in the step job. A second apply path would duplicate the guards and the audit record.
- Chosen: Call
- What does the job do when the plan has a disruptive host that is the node of its pod or the control-plane node?: The job stops before that host. It reports that the host needs a workstation run. (best practice) [sources: CONTEXT.md]
- Chosen: Stop before the host. A cluster Job must not drain or reboot its own node or the control-plane node.
- Rejected: Drain and reboot the host. The job pod would stop, and the control-plane node would lose the cluster.
- Rejected: Skip the host and continue. The apply would not complete and the result would hide the skipped host.
- How does the job keep one comment per merge and one issue per failure?: The job writes a hidden marker keyed by the merge commit SHA on the comment. It opens or updates one issue keyed by the infra repo and host. A second run changes no record. (best practice) [sources: CONTEXT.md]
- Chosen: Hidden marker and keyed issue. GitHub state is the first marker, so a second run changes nothing.
- Rejected: Search all comments on each run. A search can match a comment of another run and post a duplicate.
- Rejected: New comment on each run. The merged pull request would get many comments for one merge.
- What audit record does the job post in the comment?: The job posts the
infra.applyaudit record thatdevops infra applywrites. [sources: CONTEXT.md]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
Alternatives check of 2026-11-19: none.
Tool: none found.
Reason: Searches surfaced only Terraform/OpenTofu PR automation (Atlantis) and generic GitOps pages; none covers the project's own devops infra apply, its level gate, #5125 guards, audit record, or the stop-before-own-node rule, so no external tool fits the internal step job.
Lacks:
- No apply of a devops infra plan for a merge commit
- No drain, fresh or health guards and infra.apply audit record
- No agent level gate or stop-before-own/control-plane node rule
- No webhook-router step job or one-comment-per-merge marker
Activity
dan-petty commentedon Nov 12, 2026
Both are part of tracker #5120 (design section 8); #5120 is the umbrella and the candidate is its Phase 3 step job.devops-cli-service commentedon Nov 17, 2026
Refine cannot set this item to Ready at c58b592 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
devops-cli-service commentedon Nov 19, 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)
Searches run:
Sources:
feat(infra): apply a merged infra PR in a step job (#5130)
feat(infra): apply a merged infra PR in a step job (#5130)
devops-cli-service commentedon Nov 24, 2026
Released in v0.209.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.209.0
devops-cli-service commentedon Nov 24, 2026
Live since 2026-11-24 13:45 UTC