Repository navigation
fix(agent): gate taint removal and agent readiness on CNI conflist chaining (#667) - #681
Merged
Merged
Conversation
…t loop (#667) The re-assert loop already knows whether aether is chained in the node's active conflist -- it records a gauge on every check -- but that knowledge only ever left the process as telemetry. Nothing inside the agent could act on it, so a node that has lost the entry unrepairably keeps behaving as if it can mesh pods. Publishes it as an in-process ChainState instead. Because the loop repairs SYNCHRONOUSLY inside a check, an unchained status is by construction an UNREPAIRABLE one: the loop has already tried and refused (no primary CNI plugin in the conflist, or no known-good entry was ever observed) or the write failed. That is what makes the state worth acting on rather than merely reporting, and it is why there is no separate Repairable field. Three things are deliberate: - Observed is false until the first check completes, and callers must read that as UNKNOWN, never as chained. That is the boot window -- the moment a node is least likely to be able to mesh anything. - Since marks when the current value was FIRST seen and is preserved across re-checks that do not change it, so consumers can require the state to have persisted. A competing writer's in-place `cp -f` walks the file through a truncated state that parses as garbage; one check landing in that window must never be able to fence a node. - All five terminal paths of check() now go through a single record() that moves the gauge and the state together, so the alerting signal and the node's scheduling behaviour can never disagree. Pure refactor: no behaviour change, no new call sites, existing tests untouched. Consumers land in the following commits. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
The taint gate asked one question -- does the CNI server's Unix socket exist -- and treated the answer as "this node can mesh a pod". It cannot: the socket being up means a CNI ADD that reaches the agent can be HANDLED, not that one is ever ISSUED. Aether is a chained plugin inside another CNI's conflist, and when a competing writer strips that entry the socket keeps serving an endpoint nothing calls. Every pod scheduled onto the node then comes up successfully and UNMESHED: working base networking, no mTLS, no policy, no telemetry. The concrete hole this closes is the RETURN. An agent restarting onto a node whose conflist was stripped while it was away -- exactly the 2026-08-29 shape (#645), and the reason the taint was applied in the first place -- would stat its socket, find it fine, and remove the taint, re-opening the node to pods it cannot mesh. Both conditions are now required. Unknown counts as not-chained. The taint is only ever HELD here, never added, so waiting for evidence costs a one-second requeue and errs toward not scheduling unmeshed pods. And because the re-assert loop repairs synchronously inside a check, an unchained state that reaches the gate is one the loop has already tried and failed to repair. A nil Chain skips the condition entirely, which is what --cni-conflist-reassert=false has to mean: an operator who turns the loop off gets the pre-#667 socket-only gate, not a node that can never be untainted because nothing is left to observe the conflist. Getting that nil right is the whole reason for chainStateOf(): assigning a nil *Reasserter straight into an interface-typed field yields a NON-nil interface holding a nil pointer, the gate's `Chain == nil` check silently fails, and the first ChainStatus() call panics. There is a test pinning it, and it compares with `== nil` rather than assert.NotNil because testify reflects into the interface and reports the nil pointer inside as nil -- the same confusion that makes the bug easy to write. Wiring: the re-asserter is now constructed before the taint remover and registered with the manager afterwards, so the gate can hold it. Note what this does NOT do. It is remove-only. On a node with no taint, Reconcile returns before it ever consults the chaining state, so a node that goes unchained while running is not re-tainted here -- proposal 033 deliberately keeps the agent out of the taint-writing business. Closing that is the next commit, via the controller's guard. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…unchained (#667) The taint gate is remove-only, so it closes the RETURN (an agent coming back onto a stripped node) but not the STEADY STATE: a node that is already running and untainted when its conflist entry goes has nothing to re-arm the taint. Pods keep being scheduled there and keep coming up unmeshed. Three ways to close that were considered. The agent adding the taint itself is what proposal 033 explicitly rejected -- multiplying taint writers -- and this does not reopen it. Teaching the controller's guard about chaining would need the controller to either read the node's conflist (it cannot) or consume a metric, which is coupling the alerting path into the control plane, the #662 anti-pattern. So: the agent reports NotReady, and the guard that ALREADY keys on agent-pod readiness arms the taint. No new controller, no new RBAC, no new API, and the agent stays out of the taint-writing business. It composes with the removal gate -- the guard arms, the agent then refuses to remove. Dwell is three re-check intervals (3m). A competing writer's in-place cp -f walks the file through a truncated state that parses as garbage; one check landing in that window must never be able to fence a node. Unknown passes, so this cannot delay startup -- the boot window is already covered by the taint gate holding an existing taint. A nil ChainState passes, so --cni-conflist-reassert=false disables this exactly as it disables the taint condition. Blast radius, stated plainly because it is real: a systematic false negative would make every agent NotReady, the guard would taint every node, and no new pods could schedule fleet-wide. Bounding it: the taint is NoSchedule, not NoExecute, so running workloads are untouched; the state is unrepairable-by-construction (the loop repairs synchronously before publishing); the 3m dwell absorbs blips; the kill switch turns both mechanisms off; and the 60s re-check clears it the moment the entry returns, with no intervention. On 2026-08-29 this firing fleet-wide would have been the CORRECT outcome. No Service selects the agent, so readiness routes no traffic. One real side effect worth knowing: a RollingUpdate DaemonSet rollout will stall on a NotReady agent. Kept in its own commit so it can be reverted independently of the removal gate. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…667) Both self-heal paths -- lost CNI ADD (#567) and stale-while-Running after a reboot (#640) -- work by evicting the pod so its sandbox is recreated and CNI ADD fires again. That only heals anything if a CNI ADD would actually reach us. While aether is not chained in the node's conflist none ever will, so the replacement pod comes up unmeshed too, the sweep detects it again next pass, and the same workload is churned forever at 2/node/min against a fault eviction cannot touch. Interlocked the same way the #566 prune breaker is: reporting continues untouched -- the unmeshed_pods gauge is the alert signal and has to stay truthful -- and only the eviction is withheld. Both paths share the one evictionsBlocked decision, since both are the same futile move. This interlock fails OPEN, which is the opposite of the taint gate's choice and deliberate: a nil ChainState (--cni-conflist-reassert=false) and a not-yet-observed one both leave eviction enabled. Holding a taint costs a requeue; suppressing eviction disables a recovery that is known to work. Trading that away on a guess is the worse error. Wired with a setter rather than a 13th positional argument to NewCNIServer: the chaining state is an optional interlock, not something the server needs in order to exist. Same shape as SnapshotCache.SetMeshDNSSnapshotPath. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
The readyz check and the taint remover added two branches each to runAgent, pushing it from 14 to 16 against the gocognit threshold of 15. They are also the same idea twice -- both decide whether the scheduler may put pods on this node, both key on "can this node actually mesh a NEW pod", and they compose (the controller's guard arms the taint off readiness, the remover then refuses to drop it while the node is unchained). Putting them in one function says that, and takes runAgent back to its previous complexity. No behaviour change. The taint remover's Chain is now assigned directly rather than behind an if, which is safe precisely because chainStateOf returns a TRULY nil interface for a nil re-asserter -- the property its own test pins. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…lerts (#667) 033's removal gate asked one question -- does the CNI socket exist -- and read the answer as "this node can mesh a pod". The amendment records why that was wrong, what replaced it, and, explicitly, that the rejection of "agent re-applies its own taint on restart" STILL STANDS: the agent remains a taint remover only, which is exactly why the steady-state fix routes through the agent's readiness rather than through a second taint writer. It also records the blast radius, since a systematic false negative would taint the fleet. Incidentally drops a stray unmatched ``` fence at the end of the file, which would otherwise have swallowed the new section into a code block. docs/observability/agent-cni-alerts.yml mirrors the alerting rules (precedent: mesh-dns-alerts.yml); they are deployed from the GitOps repo, where promtool unit tests now run them in CI. The README section spells out why the obvious `== 0 or absent(...)` expression is per-node vacuous -- the gauge is pushed, so a down agent emits no series, and absent() is fleet-wide and drops the node label -- and why the counter needs a rule of its own. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
The website republishes each proposal's raw Status string on /proposals/, so a `#`-relative link in it resolves against the INDEX page, where the anchor does not exist -- mkdocs' strict build fails on the dangling link. Say where the amendment is in prose instead, and leave a note so the next person does not re-add the link. Verified with bazel test //website:site_test. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…t-gate # Conflicts: # agent/internal/cmd/BUILD.bazel
This was referenced Sep 5, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First, a correction to the issue
The issue's literal acceptance criterion is already met today. "Agent stopped and entry stripped → node stops accepting pods" is what
nodetaint.Guard(proposal 033) already does: it taints any node that has an agent pod object but no Ready one for 30s. A stopped agent is already fenced.The real holes are elsewhere, and they are about the states where the agent is up:
forget()s a node with no agent pod at all and never taints it.Both mechanisms compose: the Guard arms the taint, and the agent then refuses to remove it.
Why this matters
Aether is a chained plugin inside another CNI's conflist. The socket being up means a CNI ADD that reaches the agent can be handled; it says nothing about whether one is ever issued. A competing writer stripping the entry — kube-flannel's unconditional
cp -fon every flannel pod recreation, which a Talos bootstrap-manifest re-sync triggers (#645, the 2026-08-29 fleet-wide ~2h outage) — leaves the socket serving an endpoint nothing calls.Pods scheduled onto such a node then come up successfully and unmeshed: working base networking, so nothing looks broken, but no mTLS, no policy, no telemetry.
The commits
1.
fix(agent): publish the CNI conflist chaining state from the re-assert loopFoundational, pure refactor. The loop already knew this; it only ever left the process as a gauge. Because the loop repairs synchronously inside a check, an unchained status is by construction an unrepairable one — which is why there is no
Repairablefield.Observedis false until the first check, and callers must read that as unknown;Sincemarks when the value was first seen so consumers can require it to have persisted. All five terminal paths ofcheck()go through onerecord()so the gauge and the in-process state can never disagree.2.
fix(agent): gate startup-taint removal on CNI conflist chaining— closes H1.cniServingnow requires socket and chaining. Unknown counts as not-chained: the taint is only ever held here, never added, so waiting for evidence costs a one-second requeue and errs toward not scheduling unmeshed pods. A nilChainskips the condition, which is what--cni-conflist-reassert=falsehas to mean — the pre-#667 socket-only gate, not a node that can never be untainted.The
chainStateOfhelper is not defensive: assigning a nil*Reasserterstraight into an interface field yields a non-nil interface holding a nil pointer, so the gate'sChain == nilcheck would silently fail and the firstChainStatus()call would panic. There is a test pinning it, and it compares with== nilrather thanassert.NotNilbecause testify reflects into the interface and reports the nil pointer inside as nil — the same confusion that makes the bug easy to write in the first place.3.
fix(agent): report NotReady when the node's conflist is unrepairably unchained— closes H2. Kept in its own commit so it can be reverted independently. See the blast radius section below.4.
fix(agent): stop the ghost sweep evicting into an unchained conflist— the futility loop, below.5.
refactor(agent): fold the node-gating wiring into one helper— the two mechanisms added four branches torunAgent, pushing it 14 → 16 against gocognit's 15. They are also the same idea twice, so they now live in onesetupNodeGating. No behaviour change.6.
docs— proposal 033 amendment + the alerting rules mirrored intodocs/observability/.A3 blast radius (the medium-risk piece)
Three ways to close H2 were considered:
Worst case is real and worth naming: a systematic false negative makes every agent NotReady, the Guard taints every node, and no new pods schedule fleet-wide. Bounding it:
NoSchedule, notNoExecute— running workloads are untouched; only new scheduling stops.3 * DefaultCheckInterval) before the probe fails. A competing writer's in-placecp -fwalks the file through a truncated state that parses as garbage; one check landing in that window must never be able to fence a node.--cni-conflist-reassert=falseis a kill switch for both mechanisms.On 2026-08-29 this firing fleet-wide would have been the correct outcome.
Known side effect, called out rather than discovered later: a
RollingUpdateDaemonSet rollout will stall on a NotReady agent. Time to fence ≈ 3m dwell + ≤10s probe period + 30s Guard grace ≈ 3.5–4 minutes.If this is judged too aggressive, reverting commit 3 alone leaves H1 closed and H2 open, and nothing else breaks.
The ghost-sweep futility loop
Both self-heal paths — lost CNI ADD (#567) and stale-while-Running after a reboot (#640) — work by evicting the pod so its sandbox is recreated and CNI ADD fires again. That only heals anything if a CNI ADD would actually reach us. While aether is unchained none ever will: the replacement pod comes up unmeshed too, the sweep detects it next pass, and the same workload is churned forever at 2/node/min against a fault eviction cannot touch.
Interlocked exactly like the #566 prune breaker: reporting continues untouched — the
unmeshed_podsgauge is the alert signal and has to stay truthful — and only the eviction is withheld.This interlock fails open, which is deliberately the opposite of the taint gate's choice: nil
ChainStateand not-yet-observed both leave eviction enabled. Holding a taint costs a requeue; suppressing eviction disables a recovery that is known to work. Trading that away on a guess is the worse error. Wired with a setter rather than a 13th positional arg toNewCNIServer, matchingSnapshotCache.SetMeshDNSSnapshotPath.Residual cases, stated plainly
forget()s such nodes and never taints them. Intentional per 033 and not changed here; changing it would mean tainting nodes that were never meant to run aether.cni-install's write and the reasserter's firstcheck()leavesr.entryempty for the life of the agent process — the loop logs "no known-good entry was ever observed" and refuses to repair until the agent pod is recreated. agent-down + conflist strip = silently unmeshed pods: the gauge goes absent (not 0) and the taint gate doesn't check chaining #667 makes that state safe and visible (taint held, NotReady, no futile evictions, alert fires) but does not repair it. Filed as cni: persist cni-install's rendered entry so the re-assert loop can prime from disk #680 — do not fix here.Testing
New coverage: every terminal path of
check()maps to the right published state;Sincepreserved across unchanged checks and moved on transition; a never-started reasserter reports unknown; the taint gate across all five socket × chaining combinations plus the kill switch plus the no-taint no-op; the typed-nil trap;ReadyCheckerunknown / inside-dwell / past-dwell / recovered, with no real sleeps; the eviction interlock on both self-heal paths, its fail-open behaviour, and that reporting continues while eviction is withheld.Not unit-testable, so not claimed: that the Guard actually arms the taint in response to the agent reporting NotReady. That is integration across two binaries (agent readiness → kubelet → pod status → controller Guard) and only a live cluster proves it.
Existing
reassert_test.gotests pass unchanged.bazel build --config=lint //agent/...is clean.One note for the record: the first CI run on this branch failed the
testjob on a pre-existing gocognit violation —newCNIMetricsscored 16 against the threshold of 15 on cleanmain. CI lints only bazel-diff-impacted targets, so it had lain dormant until commit 4 touchedghostsweep.goand pulled that package into the impact set. It was fixed separately in #678, which has since merged;origin/mainis merged into this branch (merge, not rebase) and lint is green. Nothing in this PR caused or worsened it.The one gocognit regression that was mine —
runAgentgoing 14 → 16 — is fixed in commit 5 rather than waived.Not included
Chart.yamlbump. The readiness probe already hits/readyz; this only adds a check behind it.--cni-conflist-reassertis the only switch.Related
Closes #667
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr