Repository navigation
Description
Problem Description
devops infra apply drains a node before each change of class service-restart:k3s or service-restart:k3s-agent. On the control-plane node of homelab, the drain check of such a change can never pass. Thus the server node cannot get a merged k3s or kubelet change through devops infra.
A restart of k3s does not need a drain. The k3s units use KillMode=process, so a restart stops only the k3s process, and the containers keep running. Only a reboot-class change stops the pods of the node. The k3s system-upgrade-controller server plan does the same: it cordons the server node and does not drain it.
Evidence (2026-11-18)
- Apply
4d0bfc44cd6e49749758147a7e7aad64of plan8eb73261ff21..., playbookansible/playbooks/03_k3s.yaml, one host<control-plane-node>with the classservice-restart:k3s. The apply stopped at the drain check:kubectl drain --dry-run=serverreached its timeout. kubectl get pdb -A:llm/llm-gateway-db-primaryandmattermost/mattermost-db-primaryallow 0 disruptions. Both are CloudNativePG clusters withinstances: 1(k8s/llm/gateway-db.yaml,k8s/mattermost/database.yaml), and their primaries run on that node.- Result: the merged kubelet change of dan-petty/homelab is not on the server node.
Options to weigh
- Restart with a cordon and no drain. A class for a restart of the node service: cordon, run, wait for Ready, check the health of the nodes, uncordon. The host variable that selects the units can follow
devops_infra_nondisruptive_units(src/devops_cli/infra/plan.py:97). This keeps the Ready wait and the health check for the control plane. - The host variable of today. With
k3sindevops_infra_nondisruptive_units, the restart runs in the run together. That run has no cordon, no Ready wait and no health check after the restart. Homelab can do this now with no devops-cli change, but it is less safe for the control plane. - The CloudNativePG window around the drain (feat(infra): open a CloudNativePG window to drain a node #5267:
spec.nodeMaintenanceWindowwithinProgress: trueandreusePVC: true). A reboot-class change needs it. A k3s restart does not need the eviction. - A drain check rule for a single-instance CloudNativePG primary, or
spec.enablePDB: falseon the two clusters. The CRD of the cluster has the field (kubectl explain clusters.spec.enablePDB). It removes the protection of the primary for each drain, also a reboot.
Option 1 alone unblocks the k3s restart. Option 3 (#5267) is still necessary for a reboot of the node.
Acceptance Criteria
- A plan test: a changed restart of a unit that the host lists for a restart with no drain gets that class.
- An apply test with a fake cluster: a host of that class is cordoned, not drained, waits for Ready, and is uncordoned only when it was schedulable before.
- The module text of
src/devops_cli/infra/apply.pyand the infra documents name the class.
Existing Tool Considered
The k3s system-upgrade-controller plans (cordon: true for the server plan). It upgrades k3s only and does not run the playbooks of the repo, so it does not replace the apply step (as #5120 records).
Alternatives check of 2026-11-22: partly.
Tool: rancher/system-upgrade-controller (https://github.com/rancher/system-upgrade-controller), Apache-2.0, last activity 2026-11-21, maintained.
Reason: Searches found the k3s system-upgrade-controller, which cordons the server node and restarts k3s without a drain, but it upgrades k3s versions only and cannot run the repo's playbooks or join the apply step classes.
Covers:
- Cordons the node before the k3s restart
- Restarts the k3s unit with no drain
- Uncordons after the plan job succeeds
Lacks:
- Runs the repository's ansible playbooks
- Fits the plan and apply step classes
- Ready wait and node health check after restart
- Per-host selection of the units to restart
Proposed design
Problem statement
Do not drain a k3s restart. Cordon the node, restart the unit, wait for Ready and node health, and uncordon. devops infra apply drains a node before each change of class service-restart:k3s or service-restart:k3s-agent. The control-plane node of homelab cannot pass that drain check. Two CloudNativePG primaries allow zero disruptions, and they run on that node. A k3s restart does not stop the containers, because the k3s units use KillMode=process. This change adds the no-drain restart class.
Acceptance criteria
Requirement: No-drain restart class
The infra plan SHALL give a changed restart of a unit in the host no-drain list the class service-restart-nodrain:<unit>.
Scenario: Listed k3s restart gets the no-drain class
- WHEN A plan test uses a host that lists
k3sindevops_infra_restart_nodrain_units, and the playbook changes thek3sunit. - THEN The plan test finds the class
service-restart-nodrain:k3sfor that host.
Requirement: Cordon without drain
The infra apply SHALL cordon a host with a no-drain restart class, run the playbook, wait for Ready and node health, and uncordon it only when it was schedulable before.
Scenario: No-drain apply skips drain
- WHEN An apply test uses a fake cluster and one host with the class
service-restart-nodrain:k3s. - THEN The test shows a cordon step, no drain check, no drain, a Ready wait, a node health check, and an uncordon.
Requirement: Normal restart still drains
The infra apply SHALL keep the drain check and drain for a restart class that the host does not list for no-drain restart.
Scenario: Normal k3s restart drains
- WHEN An apply test uses a host with
service-restart:k3sand no entry indevops_infra_restart_nodrain_units. - THEN The test shows the drain check and drain before the restart.
Requirement: Module docstring names the class
The module docstring of src/devops_cli/infra/apply.py SHALL name the no-drain restart class and its skips.
Scenario: Module docstring names the class
- WHEN A test reads the module docstring of
src/devops_cli/infra/apply.py. - THEN The docstring contains
service-restart-nodrainand states that the drain check and drain are skipped.
Existing Tool Considered
The alternatives check in the issue body gives the verdict partly for rancher/system-upgrade-controller (https://github.com/rancher/system-upgrade-controller). The block lists what the tool covers and lacks. The proposal does what the tool lacks: it runs the repository's Ansible playbooks, adds the plan and apply step classes, waits for Ready and checks node health after the restart, and selects the units per host.
Key questions
- Which restart method should the apply use for a k3s unit?: Use option 1. Cordon the node, restart the unit, wait for Ready and node health, and uncordon. Do not drain. Do not use the run-together path of option 2. (best practice) [sources: src/devops_cli/infra/apply.py, CONTEXT.md]
- Chosen: Cordon and no drain. A k3s restart does not stop containers. The control-plane drain check cannot pass. This path keeps the Ready wait and the health check.
- Rejected: Reuse
devops_infra_nondisruptive_units. That path runs the restart in the run together. It has no cordon, no Ready wait and no health check after the restart. - Rejected: CloudNativePG maintenance window. It is necessary for a reboot. A k3s restart does not need an eviction.
- Rejected: Turn off the PDB of the single-instance primaries. It removes the primary protection for each drain, also a reboot.
- How does the plan select a no-drain restart?: Add
devops_infra_restart_nodrain_unitsto the host vars. A changed restart of a listed unit getsservice-restart-nodrain:<unit>. Follow the read ofdevops_infra_nondisruptive_units. (best practice) [sources: src/devops_cli/infra/plan.py:97, tests/infra/test_plan.py]- Chosen: New host variable. It keeps the selection in the inventory and follows the existing nondisruptive list.
- Rejected: Reuse
devops_infra_nondisruptive_units. That list means no disruptive class. It gives no cordon and no Ready wait. - Rejected: Hard-code
k3sandk3s-agent. It does not let another infra repo choose the units.
- Which apply steps run for a no-drain restart?: Use the one-host apply path with a step list. A no-drain host runs cordon, fresh check, run, Ready, node health, uncordon and alerts. It skips the drain check and drain. A normal disruptive host keeps the current steps. (best practice) [sources: src/devops_cli/infra/apply.py, src/devops_cli/models/infra.py]
- Chosen: One path with selected steps. It keeps the fresh check, the Ready wait, the health check and the alert wait in one place.
- Rejected: A second apply path. It duplicates the settle and report code.
- Rejected: A flag inside the drain step. The report would still name a drain step for a host that did not drain.
- Which apply step records the cordon?: Add
ApplyStep.CORDON. Do not reuseApplyStep.DRAIN. (best practice) [sources: src/devops_cli/infra/apply.py, src/devops_cli/models/infra.py]- Chosen: Add
CORDON. The report and the audit record then name the step that ran. - Rejected: Reuse
DRAIN. It reports a drain that did not happen.
- Chosen: Add
- Does a no-drain restart run the drain check?: No. It skips
DRAIN_CHECKandDRAIN. The API server check can fail on a PDB, and no eviction happens. (best practice) [sources: src/devops_cli/infra/apply.py, CONTEXT.md]- Chosen: Skip both. A restart does not evict a pod. The check can fail on a PDB that does not apply.
- Rejected: Keep the dry-run check. The check can reach its timeout on the control-plane node, as the evidence shows.
- Rejected: Keep the drain. The restart does not need an eviction, and the drain cannot pass.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 18, 2026
It blocks a merged kubelet change from reaching the control-plane node through the standard apply path.Both address the drain block on the control-plane node, but #5267 makes drain succeed via a CNPG window while the candidate removes the drain requirement for k3s restarts.devops-cli-service commentedon Nov 19, 2026
Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.
devops-cli-service commentedon Nov 22, 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 (6)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 22, 2026
Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.
devops-cli-service commentedon Nov 22, 2026
Plan state: branch
fix/6338-restart-k3s-with-a-cordon-and, draft pull request #6744. The pull request plans the item and closes no issue. The stage job and the step fix-plan edit this comment, and a comment of each run tells what the run did.The task groups, with the tokens of the inputs of each step, for a budget of 64000 tokens:
A model review of the plan found these points. They stop no draft, and a person judges them:
verify_format tasks (6): Group 6 writes the apply module docstring and the prose of CONTEXT.md and SECURITY.md, but its verifyuv run devops ci docsrunsdevops docs check, which only compares the generated command pages and checks that devops argv references resolve, so it passes whatever the group writes and never checks that the class and its skipped steps are named. Evidence: "uv run devops ci docs"otherat tasks (3): The apply test asserts the cordon, the absent drain check and drain, and the uncordon, but it never asserts the Ready wait or the node health check that the acceptance criterion and the no-drain scenario name, so a plan that dropped those waits would still pass the test. Evidence: "asserts the steps cordon node-3, check node-3, run node-3 and uncordon node-3 with no drain check and no drain"otherat tasks (1): Group 1 adds the no-drain class but leaves the module docstring ofsrc/devops_cli/infra/plan.py, which lists the disruptive classes, stale: it still says a restart isservice-restart:<unit>unless only the nondisruptive list names the unit, and the plan's what-changes names the docstring of the apply module only. Evidence: "service-restart:<unit>, unless the host variabledevops_infra_nondisruptive_unitslists the"18 remaining items
docs(openspec): archive the change (#6338)
devops-cli-service commentedon Nov 22, 2026
The draft pull request #6744 holds the final title and body. In mode
onofroadmap.fix_checks.mode, the watch row marks it ready when its checks pass, and a fix-checks Job repairs a failed check whose name gives the class test, lint or types. In each other case the watch row stops the item: another failed check, a cancelled check, a conflict, a fix-checks Job that ended with no repair, or another mode.Spend: 452 model requests, 33780496 input tokens, 151811 output tokens.
fix(infra): restart k3s with a cordon and no drain (#6338)
docs(openspec): archive the change (#6338)
fix: make check Tests & Coverage (shard 5 of 5) pass (#6338)
fix(infra): restart k3s with a cordon and no drain (#6338)
docs(openspec): archive the change (#6338)
fix: make check Tests & Coverage (shard 5 of 5) pass (#6338)
devops-cli-service commentedon Nov 22, 2026
Released in v0.194.2: https://github.com/dan-petty/devops-cli/releases/tag/v0.194.2
devops-cli-service commentedon Nov 22, 2026
Live since 2026-11-22 16:45 UTC