Repository navigation
fix(agent): re-subscribe SPIRE streams with backoff instead of failing - #133
Merged
Merged
Conversation
A SPIRE agent restart closes the delegated-identity subscription streams, which previously had two failure modes: - The bundle stream closing made Bridge.Start return an error, failing the controller-runtime runnable and restarting the entire agent (observed in the 2026-06-11 e2e run). - A per-pod SVID stream closing exited its goroutine silently while leaving the stale subscription entry behind, freezing that pod's SVID until expiry with no re-subscribe possible for the same netns. The bridge now maintains both stream kinds with a jittered exponential backoff reconnect loop (1s..30s, matching the registrar watch-stream policy). Backoff resets only once a response is received on the new stream, so a connect-then-instant-close flap cannot hot-loop. Cached secrets keep serving while disconnected, and SPIRE sends the full current state as the first response on every new stream, so a plain re-subscribe fully resynchronizes. Stream churn is now visible via two new counters by stream kind (bundle/svid): - aether.agent.spire.stream_failures - aether.agent.spire.stream_reconnects Tested with a fake DelegatedIdentity server over a UDS whose first stream of each kind ends after one response: the bridge re-subscribes both kinds, keeps the pod subscription tracked, and still shuts down cleanly. Co-Authored-By: Claude Opus 4.8 <[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.
Problem
A SPIRE agent restart closes the delegated-identity subscription streams, with two failure modes in the bridge:
bridge.go): the closed channel madeBridge.Startreturn an error, failing the controller-runtime runnable and restarting the entire agent. Observed once in the 2026-06-11 e2e run (bundle subscription stream closed unexpectedly).subscriptionsentry behind (blocking re-subscribe for the same netns) and freezing that pod's SVID until expiry — a delayed, hard-to-diagnose mTLS outage.Fix
UnsubscribePod.bundle/svid) so a flapping SPIRE agent shows up in dashboards rather than as mystery restarts:aether.agent.spire.stream_failures— unexpected stream ends + failed re-subscribe attemptsaether.agent.spire.stream_reconnects— streams re-established after a failureTesting
New
bridge_reconnect_test.gowith a fakeDelegatedIdentityServerover a real UDS whose first stream of each kind sends one response then ends (simulated SPIRE agent restart):TestBundleStreamReconnects—Startdoes not return, re-subscribes, and still exits nil on context cancellationTestSVIDStreamResubscribes— the pod stream re-subscribes and stays tracked insubscriptionsBackoff bounds are bridge fields (set from the constants in
NewBridge) so tests shorten them to 10ms.Full suite:
bazel test //...38/38 pass;--config=lintclean.🤖 Generated with Claude Code