Skip to content

k3s: The boot after a shutdown deletes the pods it left Failed - #42

Merged
andsens merged 1 commit into
mainfrom
claude/k3s-shutdown-pods
Nov 20, 2026
Merged

andsens merged 1 commit into
mainfrom
claude/k3s-shutdown-pods

Conversation

@andsens

@andsens andsens commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Found on nixos-homelab/example#20, which brings #40 (the longer drain) to example: the suite's shutdown subtest got past the drained check and failed on the next assertion, Failed pods with reason NodeShutdown/Terminated after the reboot.

The drain (--ignore-daemonsets) skips DaemonSet pods. At shutdown the kubelet stops them (Terminated), and while it shuts down it rejects the pods their controller keeps re-creating (NodeShutdown). In the CI log: "Pod admission denied" pod="cilium/cilium-n5htk" reason="NodeShutdown", then cilium-bjkf8. Those pods stay Failed: the pod GC collects terminated pods only past its threshold of thousands.

k3s-uncordon now deletes this node's Failed pods with either reason, before it lifts the cordon, so the node is clean once it's marked back. The pods are replaced already. The unit retries every 10 s on failure, as before, if the API isn't up yet.

Checked: checks.k3s passes locally (its shutdown subtest included, 58 s), plus deadnix and manifests. The script builds under writeShellApplication (shellcheck).

🤖 Generated with Claude Code

The drain skips DaemonSet pods. At shutdown the kubelet stops them (reason Terminated), and while it shuts down it turns away the ones their controller keeps re-creating (NodeShutdown, as Cilium's did in the example NAS suite). Those pods stay Failed: nothing collects them before thousands pile up, and the example suite's shutdown subtest fails on them. k3s-uncordon now deletes this node's Failed pods with either reason, before it lifts the cordon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andsens
andsens enabled auto-merge (squash) November 20, 2026 07:41
@andsens
andsens merged commit 4b14ccd into main Nov 20, 2026
2 checks passed
@andsens
andsens deleted the claude/k3s-shutdown-pods branch November 20, 2026 08:03
andsens added a commit to nixos-homelab/example that referenced this pull request Nov 20, 2026
nixos-homelab/shared#42: k3s-uncordon deletes the NodeShutdown and Terminated pods the last shutdown left, which the shutdown subtest failed on once shared#40 got the drain through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
andsens added a commit to nixos-homelab/example that referenced this pull request Nov 20, 2026
…status (#20)

* nas, tests: setup-secrets cluster helpers, and the suite on its exit status

The example cluster's INWX sources and destinations go through shared's kubeSecretSource and kubeSecretDestination, so they are in the cluster group that runs after k3s.

setup-secrets --auto now exits 1 for a failed fetch or destination. The suite's runs accept only what Plex being down in the VM explains (its API key, read from the workload, and the three destinations that need it) and fail on anything else. The homelab inputs are bumped to the merged setup-secrets work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* tests: The early setup-secrets runs may wait for the servarr keys

On CI the servarr apps were still waiting for their databases, which those first runs make, so their API keys, read from the workloads, couldn't be fetched yet. The two runs of the apps subtest accept that; the run after every workload is up still accepts only Plex. A destination now passes only when it was skipped for one of those keys, never when its own command failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* flake.lock: shared with the cleanup of pods a shutdown leaves Failed

nixos-homelab/shared#42: k3s-uncordon deletes the NodeShutdown and Terminated pods the last shutdown left, which the shutdown subtest failed on once shared#40 got the drain through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant