Skip to content

agent: ghost-sweep prune leaks the pod's SVID subscription (reference_not_found retries forever) #804

Closed

Description

@bpalermo

Found by the 30-minute soak on talos-main rev217 (0.92.24-9fc27c8), 2026-09-18.

Symptom

aether_agent_spire_broker_reference_not_found_total{node="main-worker-02"} climbs at ~2/min and never stops (29 at 19:40Z, 38 at 19:45Z; every other node 0). The agent log repeats a Broker subscribe failure for aether-test/svc-3-79c5b9bdf5-sr558 — SPIRE answers NotFound … pod not found on agent node. That pod no longer exists in the API server.

Data-path cost: zero (prober 0 errors on w02, no listener references the pod). It is a goroutine + a gRPC call every ~30 s, per leaked pod, for the agent's lifetime — and it permanently poisons the reference_not_found counter, which proposal 036 uses as a signal.

Mechanism

  1. The TRIPLE churn step rolled agent + proxy + svc-3 together. The svc-3 pod's CNI DEL landed while w02's agent was down; since fix(cni,agent): CNI DEL no longer blocks on the agent; stale-netns pods kept out of every snapshot (#796) #798 that DEL returns without the agent, so the agent never ran RemovePod for it.
  2. The new agent loaded the pod from storage and runResubscribeStoredPods resubscribed it (the pod was still in the API server, Terminating, so the liveness GET passed).
  3. The ghost sweep then did its job: aether_agent_ghost_sweep_orphans_pruned_total{node="main-worker-02"} = 1. But pruneOnePod (agent/internal/cni/server/ghostsweep.go) removes the storage entry and the listener and never calls spireBridge.UnsubscribePod. RemovePod (pod.go) is the only teardown path that does.
  4. The bridge classifies NotFound as transient (correct at CNI ADD, where the kubelet pod list lags), so the orphaned subscription retries at max backoff forever.

So this is not a stale storage entry — storage is clean. It is a leaked subscription. It predates the Broker API (the delegated bridge leaked the same way, silently, because SPIRE's delegated API just never answered); the Broker API's explicit NotFound plus the new counter made it visible, and #798 made the trigger (DEL without the agent) routine rather than rare.

Fix

pruneOnePod unsubscribes the pruned pod's netns. Regression test subscribes an orphan and a live pod on a started bridge, sweeps, and asserts only the orphan's subscription ended (fails without the fix).

Not doing: bounding the NotFound retry inside the bridge. With the sweep owning teardown there is no subscription left to bound, and a bound would reintroduce a failure mode at CNI ADD on a slow kubelet.

Recovery on w02 today: none needed; the leak ends when the agent next restarts.

Activity

  1. added
    bug
    on Sep 18, 2026
  2. bpalermo commented on Sep 18, 2026

    @bpalermo
    OwnerAuthor

    Validated on talos-main rev218 (0.92.24-15332e2, PR #805) by a 30-minute churned soak, 2026-09-18 T0 20:22:53Z.

    Before (rev217, same cluster): reference_not_found{node="main-worker-02"} 38 at 19:45Z → 83 at 20:09Z → 100 at 20:19Z (~1.9/min) for one pruned svc-3 pod; ended only because the deploy restarted the agent.

    After: the TRIPLE step (agent + proxy + svc-3 rolled together, 20:44:53Z) reproduced the trigger on main-worker-04:

    UTC event
    20:45:41.368 Broker NotFound for aether-test/svc-3-5784fdfcd8-kqts8 (pod … not found on agent node) — the only one
    20:45:41.793 ghost sweep: pruned orphaned pod for the same pod (+0.425 s)
    20:45:41.823 ghost endpoint deregistered
    21:05:57 reference_not_found{node="main-worker-04"} still 1, ghost_sweep_orphans_pruned_total = 1, every other node 0

    Flat for 20 minutes after the prune, where the pre-fix agent added ~2/min indefinitely. n = 1 orphan, but it is the exact production trigger rather than a synthetic one.

    Soak around it: liveness 0/44,998; mesh-DNS authoritative 0/44,999, dns_* zero; k6 http_req_failed 132/684,005 = 0.0193% (all five rate<0.01 thresholds pass); permission_denied 0; 0 restarts/taints/alerts.

    Side observations for #799: aether_agent_ghost_sweep_orphans_pruned_total is not seeded at 0 (no series = no prunes; the old generation's value lingers ~5 min after an agent restart). The svc-4 burst again produced zero reference_not_found at CNI ADD — the ADD/kubelet-list race proposal 036 anticipated has not fired once on this cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions