Skip to content

fix(agent): ghost-sweep prune ends the pruned pod's SVID subscription (#804) - #805

Merged
bpalermo merged 1 commit into
mainfrom
fix/sweep-unsubscribe-svid
Sep 18, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/sweep-unsubscribe-svid

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Fixes #804.

pruneOnePod removed a pruned pod's storage entry and listener but never unsubscribed its SPIRE stream — RemovePod was the only teardown path that did. A pod whose CNI DEL ran while the agent was down (routine since #798) is resubscribed from storage on restart, pruned by the sweep a pass later, and its subscription then retries NotFound at max backoff for the agent's lifetime.

Seen on talos-main rev217 in the 2026-09-18 30-minute soak (main-worker-02, one svc-3 pod, ~2/min, ghost_sweep_orphans_pruned_total = 1 for the same pod). Zero data-path cost; a leaked goroutine per pod and a poisoned reference_not_found counter.

  • ghostsweep.go: pruneOnePod calls UnsubscribePod for the pruned netns.
  • bridge.go: Subscribed(netns) accessor, for the test.
  • ghostsweep_unsubscribe_test.go: orphan + live pod subscribed on a started bridge; after a sweep only the orphan's subscription is gone. Fails without the fix; passes ×3 under --config=race.

No chart change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…#804)

pruneOnePod removed a pruned pod's storage entry and listener but never
unsubscribed its SPIRE stream; RemovePod was the only teardown path that did.
A pod whose CNI DEL ran while the agent was down (routine since #798) is
resubscribed from storage on restart, pruned by the sweep a pass later, and its
subscription then asks the Broker for a pod that no longer exists: NotFound,
classified transient, retried at max backoff for the agent's lifetime.

Seen on talos-main rev217 during the 2026-09-18 30-minute soak: main-worker-02
retrying one svc-3 pod at ~2/min after the TRIPLE step, with
ghost_sweep_orphans_pruned_total = 1 for the same pod. No data-path cost; the
cost is a leaked goroutine per pod and a reference_not_found counter that
stops meaning anything.

The sweep now calls UnsubscribePod for the pruned netns. Bridge gains a
Subscribed(netns) accessor for the regression test, which fails without the fix.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 15332e2 into main Sep 18, 2026
20 checks passed
@bpalermo
bpalermo deleted the fix/sweep-unsubscribe-svid branch September 18, 2026 20:11
bpalermo added a commit that referenced this pull request Sep 19, 2026
…I DEL, quiet leader-election shutdown, 036 outcome (#799) (#810)

- docs(runbook, soak README): `svid_updates{update="rotated"}` means the
  certificate changed, not that the TTL ran down. A restarted SPIRE agent re-mints
  every SVID on its node, so a spire-agent restart moves `rotated` by the node's
  pod count and leaves `unchanged` at zero (measured on rev219: 0 -> 7 pods, 0 -> 1
  node). The text added in #806 said otherwise. Rotation cadence has to exclude
  the minutes in which that node's spire-agent restarted.
- agent: RemovePod logs `pod removed: CNI DEL served` (pod, namespace, netns,
  containerID) at INFO. A successful DEL used to leave only two anonymous
  "setting snapshot" DEBUG lines, so "a late DEL cleaned this pod up" could not be
  told from "the ghost sweep pruned it" without reading snapshot timestamps.
- common/manager: controller-runtime's "error received after stop sequence was
  engaged" carrying "leader election lost" is demoted to INFO ("leader election
  released on shutdown"). Every leader-elected component logs it on a clean
  SIGTERM — the manager cancels the election context itself — and it was the last
  ERROR line on a healthy roll after #807. Exactly that record only: any other
  error after the stop sequence, and a lost lease outside shutdown, stay ERROR.
- docs(proposals/036): status and a second Outcome section — the 8-hour soak
  (4 rotation cycles, a signing-CA rotation, zero identity errors), phase 2 done,
  #804/#805, #806, #807, what is still open (phase 3, the selector gain).


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Fable 5.1 <[email protected]>
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.

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

1 participant