Skip to content

feat(infra): add node drain, uncordon, restart and reboot - #6706

Merged
dan-petty merged 5 commits into
mainfrom
feat/5128-node-drain-reboot
Nov 22, 2026
Merged

dan-petty merged 5 commits into
mainfrom
feat/5128-node-drain-reboot

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

devops infra node drain|uncordon|restart|reboot <repo> <host>... changes
the nodes of the given hosts one at a time, in order. drain runs the health
gate, the drain check and kubectl drain. uncordon runs kubectl uncordon, then the health gate. restart and reboot drain, restart the
unit of devops_infra_node_service or reboot with an Ansible ad-hoc task,
wait for Ready (a reboot also for a new boot ID), uncordon only a node that
was schedulable before, and run the health gate. A reboot shows the kernel
before and after.

An agent needs safe for uncordon and full for the others. Only a person
passes --force. The first failure stops the run and leaves the node
cordoned. Each run writes the audit record infra.node.<operation> and adds
to devops_cli_infra_runs_total. infra/ad_hoc.py runs the ad-hoc tasks,
also for devops infra status --ping.

Closes #5128

Change: openspec/changes/archive/2026-11-21-5128-node-drain-reboot/

@dan-petty dan-petty added type/feature Type feature: a new function scope/infra Docker container images, DevContainers, and infrastructure tooling labels Nov 21, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Checks on the branch (head after the rebase onto origin/main at 671f241)

  • uv run devops ci --check --only lint,format,docs,constructs,openspec,test-settings,test-tree,startup-imports,swallowed-failures,k8s,domain: all pass.
  • uv run devops ci test tests/infra tests/commands/test_infra_node.py tests/commands/test_infra_apply.py tests/commands/test_infra_status.py tests/commands/test_infra_plan.py tests/commands/test_infra_onboard.py tests/telemetry/test_telemetry_instruments.py tests/dry_run tests/lang tests/invariants tests/docs tests/config/test_infra_repos_setting.py: 1019 passed.
  • uv run mypy on the changed source paths: no issues.
  • The rebase had one conflict in src/devops_cli/infra/plan.py with feat(infra): list the roles of the pinned collections in onboard #6699 (config_env moved to ansible_facts.py). The resolved line is tool_env(tool) | _PLAN_ENV | config_env(project).

Not proven yet

  • The two live acceptance runs of the issue (node reboot dan-petty/homelab <host> at the level full by an agent, with the kernel before and after, 1 GPU allocatable, the node cordoned after and /sys/kernel/kexec_crash_size above 0; and node restart dan-petty/homelab <host>, Ready and cordoned after). These runs change real hosts, so this branch did not run them; the tests use the process fake, and only --dry-run ran. They need the merge, then the crash-capture apply of dan-petty/homelab#20 for the reboot. The run must record the audit records infra.node.reboot and infra.node.restart in this pull request or in the issue.

Owner review points

  1. --force only from a person. The issue says "no --force unless a person gives it". The command refuses an agent that gives --force (INFRA_NODE_REFUSED), because the forced drain deletes each pod that no controller owns. Say if an agent at full may give it.
  2. The health gate before the drain includes the node of the host. A reboot of a node that is not Ready stops at the gate, as the apply does. After dan-petty/homelab#22 removes the Makefile targets, a stuck node needs a person over SSH. A later item can leave the node of the host out of the gate for reboot.
  3. No question. The node commands ask no question, as kubectl drain asks none; devops infra apply asks one unless --auto-approve.
  4. The server node. A restart or a reboot of the k3s server node stops at the drain check while the CloudNativePG budgets of feat(infra): open a CloudNativePG window to drain a node #5267 allow no disruption, as the apply does.
  5. The unit render. A templated devops_infra_node_service is rendered with an ad-hoc ansible.builtin.debug task on the controller (no SSH), before the first drain.

Person steps

  • Review the diff in tuicr (tuicr -r origin/main..HEAD).

The live runs of the node commands do not need the merge. They wait until the host of the acceptance criteria is back in service, because the command refuses a host in the group offline of the inventory.
@dan-petty

Copy link
Copy Markdown
Owner Author

Correction: the live runs do not need the merge

The earlier comment says that the two live runs of the acceptance criteria need the merge. That is not correct. The command runs from a checkout of this branch with uv run devops infra node ..., and it reads the inventory of dan-petty/homelab at its origin default branch. The archived tasks.md and proposal.md of the change now say this (commit e67e2d5).

What holds the live runs now

The host of the acceptance criteria (<host> below) is out of service:

  • In the inventory of dan-petty/homelab at origin/main bd6fb04, <host> is in the group offline. The inventory comment says that the host was parked on 2026-11-13 because the node crashes, and that the owner parked the repair.
  • The node is NotReady,SchedulingDisabled. Its Ready condition is Unknown (NodeStatusUnknown) since 2026-11-19T00:20:29Z.
  • devops infra status dan-petty/homelab --ping shows <host> with "In service: no".

An agent run at the level full from this branch refuses the host before it sends a request to the cluster or to a host:

$ uv run devops infra node restart dan-petty/homelab <host>
✗ <host> is in the group offline of hosts out of service in the inventory of dan-petty/homelab, so no node command reaches it.
exit 1

Audit record (infra.node.restart, 2026-11-21T23:30:21Z): id 416a10c6df8a47b4ba7af8bbee445d7c, status refused, caller agent (claude_code), level full, commit bd6fb04, ref origin/main, hosts run: none, duration 1.9 s.

Owner decision

The live runs of node reboot and node restart wait for one of these:

  1. <host> comes back in service (out of the group offline). Then an agent runs node restart and node reboot on it, records /sys/kernel/kexec_crash_size after the boot, and posts the infra.node.restart and infra.node.reboot audit records here or on feat(infra): add node drain, uncordon, restart and reboot #5128.
  2. The owner names a different host for the live runs. Each other host in service is schedulable now, so the run is a maintenance window: the drain evicts its workloads, and the node is uncordoned after the run because it was schedulable before. The criterion "the node stays cordoned" then needs a node drain first and a node uncordon at the end.

No agent ran a drain, a restart or a reboot of a host in service for this pull request.

@dan-petty

Copy link
Copy Markdown
Owner Author

Review points for the owner

  1. The live runs of the acceptance criteria wait for you. The issue names a live node reboot and node restart at level full on a homelab host. The host it names is in the inventory group offline (repair parked since 2026-11-13) and is NotReady since 2026-11-19, so the command refuses it, as designed. A reboot of a real host is a person operation in this lab. Choose a host in service and a time, and run, from a checkout of this branch:
    uv run devops infra node restart dan-petty/homelab <host>, then uv run devops infra node reboot dan-petty/homelab <host>, and post the audit records here. The merge does not need these runs first.
  2. --force on a drain. Now only a person may give --force; an agent at level full is refused. Keep this, or let an agent at level full give it.
  3. The health gate before a drain counts the node of the host itself. So node reboot cannot recover a node that is NotReady; such a node needs a person over SSH, also after dan-petty/homelab#22 removes its Makefile targets. A later item can leave the node of the host out of the gate for a reboot.
  4. Fixed in 7ecca72: devops infra --help now shows the help of the node group (it was empty), with a test.

@dan-petty
dan-petty marked this pull request as ready for review November 21, 2026 23:51
@dan-petty
dan-petty merged commit 8af846c into main Nov 22, 2026
29 checks passed
@dan-petty
dan-petty deleted the feat/5128-node-drain-reboot branch November 22, 2026 00:21
dan-petty-release Bot added a commit that referenced this pull request Nov 22, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.191.0](v0.190.0...v0.191.0)
(2026-11-22)


### Features

* **infra:** add node drain, uncordon, restart and reboot
([#6706](#6706))
([8af846c](8af846c)),
closes [#5128](#5128)
* **monitoring:** keep the cAdvisor container_threads series
([#6711](#6711))
([349adda](349adda))


### Bug Fixes

* **ci:** check release image job times in devops ci job-time
([#6635](#6635))
([1b1a25e](1b1a25e))
* **k8s:** narrow the in-namespace egress of the object store
([#6712](#6712))
([f14cb8b](f14cb8b)),
closes [#6707](#6707)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/infra Docker container images, DevContainers, and infrastructure tooling type/feature Type feature: a new function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(infra): add node drain, uncordon, restart and reboot

1 participant