Skip to content

ghost-sweep prune breaker is permanently tripped on every node: API-confirmed orphans count toward the 30% fraction, so cleanup can never run #670

Closed

Description

@bpalermo

Summary

The mass-delete circuit breaker added in #566 is permanently blocking all ghost-sweep pruning on every node of talos-main, and the condition is self-reinforcing: once stale records exceed the breaker's 30% fraction, cleanup can never run again, so staleness only grows.

Measured live during the 2026-09-03 soak (rev190/0.91.3-a14df22):

node aether_agent_storage_pods actual mesh-managed pods stale stale %
main-worker-01 35 12 23 66%
main-worker-05 17 9 8 47%
main-worker-04 12 5 7 58%
main-worker-02 15 9 6 40%
main-worker-03 13 8 5 38%

Every node is above pruneBreakerFraction = 0.30. All five agents log ghost sweep: prune circuit breaker TRIPPED; refusing to prune roughly once a minute, and aether_agent_ghost_sweep_prune_breaker_tripped_total climbed exactly 10 per 600s on every node for the full 170 minutes before an agent roll — perfectly linear, i.e. every single sweep pass is refused. The counter resets with the pod and immediately resumes the same cadence, so this is a standing condition, not a transient.

Mechanism — the breaker gates API-confirmed orphans, which can never be false positives

In agent/internal/cni/server/ghostsweep.go, classifyPruneCandidates builds one candidate set containing two very different kinds of entry:

pruneStaleStoragePods then applies the breaker to the combined set:

candidates, ... := s.classifyPruneCandidates(...)
if s.pruneBreakerTrips(ctx, len(pods), len(candidates)) {
    return pods, 0, 0, ..., true   // refuse the whole pass
}

So a large number of legitimately-orphaned records — pods Kubernetes confirms are gone — trips a breaker that exists to guard against a different failure mode, and the orphans are never removed. Because they are never removed, the next pass sees the same fraction and refuses again. The breaker's protection has become a deadlock.

Note this is a consequence of soak churn working as intended: ~30 rolls per run produce a steady trickle of missed CNI DELs, staleness crosses 30%, and cleanup stops permanently from that point on.

Why this probably matters much more than the metric suggests

This is the substrate the #638 H1 hypothesis needs. From the #638 design exploration:

  • stale storage → the endpoint stays in the registry (etcd Put with no lease/TTL; deregistration is entirely agent-driven);
  • CNI IPAM recycles the dead pod's IP to a new pod, during a roll overwhelmingly a pod of the service being rolled;
  • the client dials it, receives that pod's genuine SVID, and the SAN matcher rejects → CERTIFICATE_VERIFY_FAILED.

And the correlation is direct: worker-01 has by far the most stale records (23) and is the only node that has ever shown non-zero envoy_cluster_ssl_fail_verify_san_total. #638's own separate defect — the ghost sweep matching ghosts to live pods by IP alone, ignoring the service — then makes any ghost whose IP was recycled permanently un-reapable, on top of the breaker refusing the whole pass anyway. Two independent bugs protecting the same garbage.

Proposed fix

Exempt API-confirmed orphans from the fraction breaker. They are ground truth and cannot be the #566 false positive, which was specifically about netns stat failures. Concretely: compute the breaker fraction over netns-derived candidates only, and prune orphans unconditionally (still subject to the existing per-pass rate limiting and the nodePodsOK guard, which already skips all pod-absence pruning when the API list fails — that is the real protection against a bad API read).

Secondary, worth considering together:

  • Alert on aether_agent_ghost_sweep_prune_breaker_tripped_total increasing — it has been firing every minute on every node and nobody noticed.
  • Alert on, or at least expose, aether_agent_storage_pods versus the count of mesh-managed pods on the node; the ratio is a direct staleness signal.
  • Consider whether a tripped breaker should be loud rather than a per-minute log line — its current behaviour is indistinguishable from healthy operation to anyone not reading agent logs.

Acceptance

Found during the 2026-09-03 soak #662 agent-roll checkpoint. Related: #566 (the breaker), #638 (stale endpoints → mis-identity, likely downstream of this), #641/#650.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions