Skip to content

fix(agent): emit one consistent xDS snapshot to stop resource clobbering - #75

Merged
bpalermo merged 1 commit into
mainfrom
fix/agent-unified-snapshot
Jun 7, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/agent-unified-snapshot

Conversation

@bpalermo

@bpalermo bpalermo commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Problem

The cache had four separate snapshot generators, each setting a partial snapshot for one resource type (listeners; clusters/endpoints/routes; secrets; vhosts). go-control-plane's SetSnapshot replaces the entire node snapshot, so each update dropped every other resource type from Envoy.

Observed live on talos-main with a managed pod present: the proxy log shows LDS add/update listener immediately followed by remove listener in a cycle (cluster + secret updates fighting the listener update), so the outbound listener was usually absent → curl: (7) connection refused. SDS secrets likewise never reached active.

This was masked before because clusters were loaded once at startup (with 0 services) and SVID subscription never succeeded — once #71 (dynamic cluster refresh) and #72/#74 (working SVID subscription) started pushing cluster/secret snapshots, the clobber became continuous.

Fix

Funnel every mutation through a single generateSnapshot that assembles a complete, consistent snapshot — listeners + clusters + endpoints + outbound route config + secrets — from the in-memory maps. Nothing is rebuilt, so a full snapshot stays cheap. The per-type generators now delegate to it. Removed the dead generateVhostsSnapshot (VHDS was never wired; the outbound listener uses RDS).

Adds a regression test asserting the node snapshot holds listeners, clusters, routes and secrets simultaneously after a trailing secret update.

Note

Depends on #73 (SnapshotCache nil-map init) to start with pods in storage.

The cache had separate generators that each set a partial snapshot for one
resource type: listeners, clusters/endpoints/routes, secrets, and vhosts. Because
go-control-plane's SetSnapshot replaces the entire node snapshot, each update
dropped every other resource type from Envoy. With a managed pod present, the
agent churned listeners on/off as cluster and secret updates fought them
(observed live: lds add/remove cycling, "no outbound listener" -> connection
refused), and SDS secrets never went active.

Funnel all mutations through a single generateSnapshot that assembles a complete,
consistent snapshot (listeners + clusters + endpoints + outbound route config +
secrets) from the in-memory maps — nothing is rebuilt, so it stays cheap. The
per-type generators now delegate to it. Drop the unused generateVhostsSnapshot
(VirtualHostType/VHDS was never wired; the outbound listener uses RDS).

Adds a regression test asserting the node snapshot holds listeners, clusters,
routes and secrets simultaneously after a trailing secret update.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@bpalermo
bpalermo merged commit 449003c into main Jun 7, 2026
10 checks passed
@bpalermo
bpalermo deleted the fix/agent-unified-snapshot branch June 7, 2026 17:33
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.

1 participant