Repository navigation
fix(agent): exempt API-confirmed orphans from the prune circuit breaker (#670) - #672
Merged
Merged
Conversation
…er (#670) The #566 mass-delete breaker measured its fraction over the COMBINED prune set: API-confirmed orphans (the node-scoped pod List says the pod does not exist here) plus netns-derived candidates (the netns path has been gone for N consecutive passes). Only the second class can be the correlated-stat false positive the breaker exists to catch, but counting the first made the guard self-reinforcing — once a node's orphan backlog crossed 30% of storage every pass was refused, so the backlog could only grow, and an agent roll reset the counter but not the condition because the staleness lives in on-disk storage the fresh process re-reads. Measured on talos-main during the 2026-09-03 soak: 92 storage records for 39 live mesh-managed pods fleet-wide (57.6% stale; worker-01 at 36 records for 14 pods), with prune_breaker_tripped climbing +15 per 15 minutes on every node — exactly one refusal per sweep pass, every pass. The fraction is now computed over the netns-derived class alone, in both numerator and denominator, and a trip withholds only that class: API-confirmed orphans prune regardless, still subject to the per-pass rate limiting. The real protection against a bad API read is unchanged — nodePodsOK is false when the List fails, which classifies no orphan at all, so no pod-absence pruning happens in that pass. Instrumentation: the breaker had been firing every minute on every node for weeks unnoticed, so a counter alone is not a detection mechanism. Adds aether.agent.ghost_sweep.prune_breaker_engaged (gauge, recorded every pass) so a standing trip is a state an alert can match, and aether.agent.storage.stale_pods (gauge) so the backlog is visible as DETECTED rather than only as what was successfully pruned. The ERROR line is now loud on the transition in and out of the tripped state and rate-limited to once every 30 passes while it stands. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 4, 2026
newCNIMetrics has been at cognitive complexity 16 against the lint limit of 15 since #672 (cf68f1b) added the prune_breaker_engaged and storage.stale_pods gauges as its fifteenth and sixteenth sequential error-checked registrations. That PR's CI test job passed, so the violation stayed dormant on main until any PR that put //agent/internal/cni/server back in the bazel-diff impact set — which is exactly what #676 (mesh-dns) and the #667 branch now do, and both go red on it. Pure mechanical extraction into registerSweepInstruments (ghost-sweep counters and the prune-breaker gauge) and registerLifecycleInstruments (the unmeshed and storage gauges, liveness instruments, identity-override counter). No metric names, descriptions, units or registration order change. Verified with fail_on_violation on //agent/internal/cni/server/... and the package tests. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 4, 2026
newCNIMetrics is at cognitive complexity 16 against the lint limit of 15 on main, and no PR ever failed CI for it. #671 (763f5b3) added the fifteenth registration; #672 was branched before #671 merged, added two more to a file it saw at 13, and its CI head (f5d540a) honestly measured 15 and passed. The squash of #672 onto main produced the sixteenth. Nothing lints main after a merge, so the violation surfaced only when #676 and the #667 branch put //agent/internal/cni/server back into a PR's bazel-diff impact set. Pure mechanical extraction into registerSweepInstruments (ghost-sweep counters and the prune-breaker gauge) and registerLifecycleInstruments (the unmeshed and storage gauges, liveness instruments, identity-override counter). No metric names, descriptions, units or registration order change. Verified with fail_on_violation on //agent/internal/cni/server/... and the package tests. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 4, 2026
#678) newCNIMetrics is at cognitive complexity 16 against the lint limit of 15 on main, and no PR ever failed CI for it. #671 (763f5b3) added the fifteenth registration; #672 was branched before #671 merged, added two more to a file it saw at 13, and its CI head (f5d540a) honestly measured 15 and passed. The squash of #672 onto main produced the sixteenth. Nothing lints main after a merge, so the violation surfaced only when #676 and the #667 branch put //agent/internal/cni/server back into a PR's bazel-diff impact set. Pure mechanical extraction into registerSweepInstruments (ghost-sweep counters and the prune-breaker gauge) and registerLifecycleInstruments (the unmeshed and storage gauges, liveness instruments, identity-override counter). No metric names, descriptions, units or registration order change. Verified with fail_on_violation on //agent/internal/cni/server/... and the package tests. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
bpalermo
added a commit
that referenced
this pull request
Sep 5, 2026
…efore merging (#679) (#685) PR CI validates a PR head against that PR's merge-base, and nothing validated main after a merge. Two PRs that each pass against their own base can combine into a state neither was ever tested in — #671 and #672 each added CNI metric registrations against a base without the other, and the second squash put newCNIMetrics at gocognit 16/15 on main, surfacing days later on the unrelated PRs #676/#677. Add .github/workflows/main.yaml (`main-post-merge`): on every push to main it runs the same build+lint+unit-test leg ci.yaml runs, with the bazel-diff impact set computed as the merge commit vs its first parent (HEAD^), falling back to a full //... build+test when bazel-diff cannot compute it. --config=ci implies --config=remote, which pins TestRunner to the local strategy, so tests stay local exactly as they are on the PR path. The pull_request path is untouched and `ci` remains the only required status check. ci-impacted-targets.sh never assumed a PR merge-base functionally, but its docs did; retitle them for the two callers and add the new workflow to the seed-file list so editing it forces a full run. The preventive half — branch protection required_status_checks.strict — is a repo settings change applied alongside this PR, not code. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
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.
Fixes #670.
Mechanism
classifyPruneCandidatesbuilds one candidate set out of two classes that fail in completely different ways:nodePodsOK && !podInNode(nodePods, p). The node-scoped Kubernetes pod List says the pod does not exist on this node. Ground truth, deliberately not gated by the netns hysteresis.supersededsibling from fix(agent): re-assert the aether-cni conflist entry when a competing writer strips it (#645) #650) — the netns path has been gone forghostNetnsFailThresholdconsecutive passes. This is the class that produced agent: ghost-sweep prune needs a mass-delete circuit breaker (power-blip incident 2026-07-19) #566's false positives, when a transient fleet-widestatfailure made every pod look dead at once during the 2026-07-19 power blip.pruneStaleStoragePodsthen applied the breaker to the combined set and refused the whole pass on a trip. So a large number of legitimately-orphaned records — records Kubernetes confirms are garbage — tripped a breaker built to guard a different failure mode, and because they were never removed, the next pass saw the same fraction and refused again. The protection had become a deadlock, and a self-reinforcing one: the backlog could only grow.An agent roll resets the counter but not the condition. The staleness lives in on-disk storage the fresh process re-reads, so the breaker re-arms within ~60s on the new process.
Live measurements (2026-09-03 soak, rev190/0.91.3-a14df22)
End of an 8h soak: 92 storage records for 39 live mesh-managed pods = 57.6% stale fleet-wide (worker-01: 36 records / 14 pods). Every node above
pruneBreakerFraction = 0.30:aether_agent_storage_podsaether_agent_ghost_sweep_prune_breaker_tripped_totalclimbed +15 per 15 minutes on every node — exactly one refusal per sweep pass, every pass, perfectly linear for the full 170 minutes before an agent roll, then resumed the same cadence on the fresh pod.The fix
Compute the breaker fraction over netns-derived candidates only, in both numerator and denominator, and prune API-confirmed orphans unconditionally (still subject to the existing per-pass rate limiting and the
nodePodsOKguard). On a trip, only the netns-derived candidates are withheld; the pass is no longer refused wholesale.Two small pure helpers keep
classifyPruneCandidatesuntouched andpruneStaleStoragePodsunder the gocognit-15 threshold:pruneCounts(pods, candidates)→(netnsCandidates, netnsEligible, orphanEntries).netnsEligibleis every stored entry the API did not confirm orphaned, so the fraction is measured over the class at risk of netns misclassification. This is stricter than the old whole-storage denominator, not looser.orphanCandidates(candidates)narrows the set to orphans when the breaker trips.breakerTrippedis still returned and still interlocks both self-heal eviction paths.#566 protections preserved, and how each is proven
ghostNetnsFailThresholdconsecutive failures)classifyPruneCandidatesis unchangedTestSweepHysteresisTransientNetnsFailure,TestSweepPrunesStalePods(both unmodified)podRunningWithIP)TestSweepAPICrossCheckVetoesPrune(unmodified)TestSweepBreakerStillRefusesCorrelatedNetnsFailure(10 pods, everystatfails, API confirms all 10 exist → 0 pruned, engaged gauge 1, trip counter positive); plus unmodifiedTestSweepMassBreakerRefusesPrune,TestSweepMassBreakerMetricAndInterlocknodePodsOK == false→ no pod-absence pruning at allTestSweepNoPodAbsencePruningWithoutNodePodList(0 pruned, 0 evicted, streaks dropped,stale_podsnot even recorded)breakerTrippedTestSweepEvictsStaleRunningPodAfterThreshold,TestSweepStaleRunningEvictionRateLimitedAndBudgetShared,TestSweepStaleRunningInterlockedOnBreaker(all unmodified)TestSweepPrunesSupersededEntry(unmodified)New tests
TestSweepPrunesMajorityOrphansDespiteBreaker— the regression test. 7 orphans + 3 live, netns pins all lingering (the talos signature): all 7 prune in one pass, breaker gauge reads 0.TestSweepBreakerStillRefusesCorrelatedNetnsFailure— the agent: ghost-sweep prune needs a mass-delete circuit breaker (power-blip incident 2026-07-19) #566 incident, must still block. It does.TestSweepMixedOrphansAndNetnsStale— 7 orphans + 4 netns-stale + 6 healthy: orphans prune, the 4 netns candidates stay withheld because they are 4/10 of their own class, above the fraction.TestSweepNoPodAbsencePruningWithoutNodePodList— the invariant.Verified empirically that (1) and (3) fail against the pre-fix logic (
should have 3 item(s), but has 10) while (2) and (4) pass on both — i.e. the new tests bracket exactly the behaviour change and nothing else. Every pre-existing test passes unmodified; none were weakened.Instrumentation decision
The breaker was silent-by-log: it fired every 60s on every node for weeks and nobody noticed, because a counter with no alert reads as ordinary sweep activity and an ERROR line that never stops is indistinguishable from wallpaper. A counter is not a detection mechanism for a standing condition. Three changes:
aether.agent.ghost_sweep.prune_breaker_engaged(Int64Gauge, recorded every pass, zero included). Turns "the breaker is standing open" into a state an alert can match, rather than a slope someone has to notice. Recording zeros matters: the gauge falls back to 0 the moment the condition clears, so the alert self-resolves.aether.agent.storage.stale_pods(Int64Gauge) — storage entries with no Kubernetes pod on this node, as detected, whether or not they were prunable.orphans_prunedreads zero both when there is no staleness and when cleanup is blocked; this gauge tells those two apart, which is exactly the signal that was missing. Not recorded whennodePodsOKis false, so a failed List is never reported as "zero stale".first_trip=true), then once everypruneBreakerRelogPasses = 30passes (~30 min) while it stands, DEBUG in between — plus a new WARN on the tripped→clear transition so recovery is as visible as the trip.The existing
prune_breaker_trippedcounter is kept unchanged.Alert rules I would write (GitOps repo, not here):
The second one is the load-bearing one — it would have caught this within half an hour of the backlog forming, independently of whether the breaker was the reason cleanup stalled.
Verifying on-cluster after deploy
aether_agent_ghost_sweep_prune_breaker_tripped_totalstops climbing on every node (it was exactly +1/pass).aether_agent_ghost_sweep_prune_breaker_engagedreads 0 steadily.aether_agent_storage_podsconverges down toward each node's mesh-managed pod count — compare againstcount(kube_pod_info{node="..."} and on(pod,namespace) kube_pod_labels{label_aether_io_managed="true"}), or justkubectl get pods -A -l aether.io/managed=true --field-selector spec.nodeName=main-worker-01 | wc -l. Worker-01 should fall from ~35 toward ~12. Expect this within a few sweep passes: orphans are pruned per pass at whatever rate they classify, with no eviction involved.aether_agent_storage_stale_pods(new) drops to ~0 and stays low;aether_agent_ghost_sweep_orphans_pruned_totalshows the one-time catch-up burst then settles to churn rate.prune circuit breaker CLEAREDline per node, then silence.lost_add_evictions/stale_running_evictionsburst (the eviction paths are untouched and still interlocked), nounmeshed_podschange.Note on #638
This plausibly removes the substrate of #638's H1, though not #638 itself. The chain is: stale storage record → the endpoint is never deregistered (etcd
Putwith no lease/TTL; deregistration is entirely agent-driven) → CNI IPAM recycles the dead pod's IP, during a roll overwhelmingly to a pod of the service being rolled → a client dials it, gets that pod's genuine SVID, and the SAN matcher rejects. Draining the stale-record backlog removes the ghost endpoints that recycled IP can collide with, and the correlation is suggestive: worker-01 carried by far the most stale records (23) and is the only node that has ever shown non-zeroenvoy_cluster_ssl_fail_verify_san_total.Two caveats against calling #638 fixed here. First, #638's own separate defect — the ghost sweep matching ghosts to live pods by IP alone, ignoring the service — means a ghost whose IP has already been recycled stays un-reapable even with the breaker fixed; that needs its own change. Second, the 4.25s cross-wiring window observed at TRIPLE-cluster is short enough to be a genuine race rather than a standing-garbage effect. So: this should shrink #638's blast radius materially and is a prerequisite for testing H1 cleanly, but #638 should stay open and be re-measured on the next soak after this deploys.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr