Repository navigation
fix(quic): a twin pair Envoy has subscribed to is never forgotten — dormant while its source or destination is away, republished on return, pruned only when the subscription is gone (#1036) - #1038
Merged
Conversation
…set re-subscriptions are answered absent, and stale persisted pairs are pruned (#1033) rev245 (the first talos deploy of #1032) logged observed_pairs == local_identities x 2 on every node: the fresh agent admitted, and persisted, every twin the running proxy re-stated on the new xDS stream, i.e. the SAs x destinations fan-out the previous agent had built up front. - agent/internal/xds/quicdemand: classifies a delta CDS request's quic: names as first use (named on a later request, not held), resubscribed (a live on-demand subscription re-stated on a fresh stream) or held-only (initial_resource_versions via the wildcard). - Held-only twins admit nothing (RestoreQUICTwin is gone); an unpersisted one is answered absent in removed_resources and Envoy drops it; the next routed request is a real on-demand fetch. - Re-subscribed twins are served (ResumeQUICSubscriptions): Envoy's ODCDS manager keeps one subscription per name for the process lifetime and skips every later request for it, so answering one absent strands the pair (503 NC at the on_demand timeout). Shown live by the mtlspool strand control. - Post-start prune: a persisted pair with no on-demand fetch or re-subscription within --east-west-quic-pair-fetch-window (default 1h) of the agent starting is dropped with its twin; one log line per node. Gates (each seen red): server delta test (24 held twins, empty persisted set -> 0 admitted, 24 removed; red: admitted=24), cache prune test, live mtlspool agent-restart tests. Closes #1033 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…ormant while its source or destination is away, republished on return, pruned only when the subscription is gone (#1036) Envoy's ODCDS manager keeps one subscription per cluster name for the life of the process. When the agent removed a twin the proxy had fetched on demand (its source ServiceAccount's last pod left the node, or its destination left the allow-list / dependency set), Envoy dropped the cluster and kept the subscription; when a pod of that ServiceAccount came back, every request to the twin was "already subscribed, skipping" -> 503 NC at the 2 s on_demand timeout, until the proxy restarted. quicdemand.Ledger records which twins the proxy holds an ODCDS subscription for (first-use requests, refused or not, and fresh-stream re-subscriptions). On removal evidence a subscribed pair goes dormant: its twin leaves the snapshot, the pair is persisted in ObservedUpstreams.dormant_quic_pairs, and the snapshot that sees it valid again republishes the twin with no request. A dormant pair is pruned only when a fresh stream's first CDS request does not re-subscribe it (agent restart against a proxy that no longer holds it, or a hot-restart child). The fetch-window prune never touches a dormant or subscribed pair. Gates: //test/mtlspool TestOnDemandQUICDormantTwinRepublishedWhen{SourceReturns, DestinationIsRelisted} (dormant: republished in 22 ms with no request, then 200/HTTP3 in 6.7 ms; forget_control: 503 in 2.000 s), cache/server/ledger unit tests for the transitions, persistence and fresh-stream/generation prune. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Resolves the 038 Selection conflict with #1034 (#1021 per-request cost) by keeping both paragraphs: #1033's admission rule, then #1021's cost findings. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…ant-twin-pairs Keeps both sides: #1034's quic_cost_test.go and 038 per-request-cost paragraph alongside #1036's quic_dormant_test.go and dormant-pair paragraph. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…cleanup TestQUICDormantOnlyForSubscribedPairs flaked 2/8 under --config=race with "TempDir RemoveAll cleanup: directory not empty": a 1 ms debounced flush landed after the test returned. newQUICDemandCacheWith now registers a FlushObservedUpstreams cleanup, which runs before TempDir's (LIFO) and serializes with any in-flight write. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…airs main's tree at c8f7df8 is identical to the #1035 branch head (556dbe8) this branch already merged, so this merge records the squash as an ancestor and keeps this branch's tree: main + the #1036 changes only. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Sep 28, 2026
bpalermo
added a commit
that referenced
this pull request
Sep 29, 2026
Brings #979 up to date with 36 commits of main (demand-scoped twins #1020/#1032, fresh-stream classifier #1033/#1035, dormant-pair ledger #1036/#1038, per-twin EDS names #1012/#1029, the twin certificate gate #1051, the ODCDS always-answer override, --east-west-quic-idle-timeout #1063, L4 stat keys #1043, access-log timing #1048, the identity gate #1055, hot-restart knobs #1068 and the carried Envoy patches) while keeping #979's intent: no allow-list, every destination in the node's dependency set is QUIC-eligible. Resolution: - cache: quicServices / SetEastWestQUICServices removed. armsFor gives arms to every default, identity-ready, non-waypointed entry whose service is in the dependency set (the same rule recordQUICPair admits by, so no route names a twin the agent would refuse); twins stay demand-scoped. The destination_not_quic_enabled refusal/prune reason is gone. - quicpairs: the dependency-set prune now waits for the pod set like the source prune does -- the allow-list used to force its destinations into the set, and without it the first snapshot after an agent restart dropped every restored pair (TestQUICDemandPairSurvivesAgentRestart was red). - fan-out log: allow_listed_services dropped; observed_pairs and awaiting_client_cert kept. - chart 1.0.12: eastWestQuicServices removed, eastWestQuicIdleTimeout and its parentShutdownTime check kept. - e2e/eastwest-quic.sh: main's demand-scoped E1/E4c/E6 + #979's QUIC_DNS_SANS negative control; h2only/E3 removed; E6 dials quic-a and its idgate-* pairs are excluded from the driven-pair count. eastwest-quic-hotrestart.sh's h2 control is now the weighted GAMMA split (the one h2-by-design path). - tests, runbook, soak README, configuration.md, 038 rewritten for the unconditional state. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
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.
Mechanism
Envoy's ODCDS manager keeps one subscription per cluster name for the life of the process. Before this PR, the agent removed a twin the proxy had fetched on demand in two cases:
pruneQUICPairsLocked,source_left_node);When that happens, Envoy drops the cluster and keeps the subscription. Every later on-demand request for the name is
already subscribed, skippinginside the proxy and never reaches the agent. So when a pod of that ServiceAccount came back to the node (a Deployment roll does this all the time), its route selected a name Envoy would never ask for again. Every request then 503'dNCat the 2 son_demandtimeout until the proxy restarted. The soak's churn on talos rev245 would hit this.This is now reproduced live, not only inferred. The forget control below is exactly the #1036 sequence: fetch, prune on source departure, source returns, request.
Fix
The subscription is still open, so the control plane can push the twin again at any time and Envoy takes it without a new request. The agent therefore never forgets a pair Envoy has subscribed to.
The ledger.
agent/internal/xds/quicdemand/ledger.go(new) addsLedger[K], which records which twins the proxy holds an ODCDS subscription for:It lives in
quicdemandso the live gate runs the agent's ledger, not a copy of it. That is the same reason #1035 put the classifier there.Pair lifecycle (
cache/quicpairs.go):(source_left_node, dormant). A pair with no subscription behind it is forgotten as before. The proxy drops such a cluster outright, and its next request is ordinary first use.reviveDormantQUICPairsLocked), and logsrepublished dormant east-west QUIC pairs ….source_not_localrace) is parked dormant. Only the refused request 503s, not every one after it.RestateQUICSubscriptionsruns on every fresh stream's first CDS request, including one that re-subscribes nothing. That request's re-subscribed set is the proxy's full subscription set, so a dormant pair it does not name is pruned. This covers an agent restart against a proxy that no longer holds the subscription, and a proxy generation change: a hot-restart child has no ODCDS subscriptions, and its first request names none.quicdemand.ClassificationgainsFreshso the observer can tell. The observer's non-fresh re-subscriptions still go throughResumeQUICSubscriptions, which does not touch the rest of the ledger.ObservedUpstreams.dormant_quic_pairsfield (field 3; an older agent ignores it) and restored at load. A restored dormant pair whose source is on the node once the pod set is known is republished by the first snapshot after that, before any request. One whose source is still away stays dormant until the fresh stream keeps it or prunes it.ledger.godocuments the ledger's rule.Gates, each seen red
How red was produced for the unit gates and the live dormant arm: the ledger was made to forget, i.e. #1035's behaviour.
Retirealways returnedfalseandParkwas a no-op. Every new cache and server test failed:TestQUICDormantPairRepublishedWhenSourceReturns:expected [quic:echo…@demo/source-a] actual [](not dormant, not persisted:"[]" should have 1 item(s)).…WhenDestinationIsRelisted:re-listed: both twins republished with no request, elements differ.…PersistAcrossAgentRestart:"[]" should have 3 item(s), but has 0.…PrunedOnProxyGenerationChangeandTestQUICRefusedFirstUseIsParkedDormantfailed the same way.server/TestOnDemandObserver_FreshStreamRestatesSubscriptionsForDormantPairs:a subscribed, unservable twin is kept dormant,expected [quic:echo…@demo/away] actual [].dormantarms failed withthe dormant twin must be republished with no request (issue #1036), condition never satisfied.The ledger was then restored, and all of these are green.
1. Live, source leaves and returns (
//test/mtlspool,TestOnDemandQUICDormantTwinRepublishedWhenSourceReturns; delta ADS, pinned proxy, real HTTP/3 destination that requires the client certificate). Source A fetches its twin on demand (200 … HTTP/3.0 in 26.2ms), A's ServiceAccount leaves (twin removed), and A's ServiceAccount returns.dormant:pair valid again: proxy holds [quic:echo.demo.aether.internal@demo/source-a] after 22.40114ms, with no request. The xDS trace shows only the twin's EDS/SDS re-subscribes, and the agent'srequestslist still holds only the original first use. Thensource-a after the pair is valid again: status=200 san=".../sa/source-a" proto="HTTP/3.0" in 6.654974ms.forget_control(fix(quic): a twin pair is admitted only on real first use — held-only twins are dropped on a fresh stream, live re-subscriptions keep serving, stale persisted pairs are pruned (#1033) #1035's rule, the red):status=503 … in 2.000099268s, and no CDS request ever reaches the control plane (Envoy never re-requests a name it is subscribed to). fix(quic): a twin pair is admitted only on real first use — held-only twins are dropped on a fresh stream, live re-subscriptions keep serving, stale persisted pairs are pruned (#1033) #1035'sTestOnDemandQUICSubscribedTwinsServedAfterAgentRestart/strand_controlis kept unchanged as its negative control.2. Live, destination delisted and re-listed (
…WhenDestinationIsRelisted). Same two arms and the same result: thedormantarm is republished with no request and returns 200/h3, and theforget_controlarm 503s at 2.000 s.Harness note: the live gate waits for Envoy to finish tearing down the removed twin before the "return". It waits until the proxy has released the twin's EDS name and its certificate's SDS name. The reason is a go-control-plane artefact, not the behaviour under test. If the return lands inside the same few milliseconds, the delta server can record a response for a name the proxy is unsubscribing and then not re-send it when the re-added twin subscribes again. A real return (a new pod, a re-listing) comes seconds later.
3. Unit (cache, server and
quicdemand):TestLedgercovers the transitions.cache/quic_dormant_test.go:RestateQUICSubscriptions(nil));server/quic_restate_test.gochecks that the observer hands the cache every fresh stream's re-statement, including an empty one.Runs
bazel … test --disk_cache= --test_output=errors //agent/... //test/...: 39/39 pass.--config=race //agent/internal/xds/...: 8/8, clean.build --config=lint --@aspect_rules_lint//lint:fail_on_violation //agent/... //test/...and//api/...: clean.//:formatand//:gazellewere run.Docs
docs/runbook.md, new section "Stranded twin: 503 NC at 2 s for a source that came back (quic: a pruned on-demand twin is stranded if its source ServiceAccount returns to the node — Envoy never re-requests a subscribed ODCDS name (503 NC forever) #1036)":NCwithduration_ms≈ 2000, the proxy'sODCDS-manager: … already subscribed to, skipping, and silence on the agent side;The "Reading twin count against pairs" paragraph now points at it.
038 Selection: a paragraph on dormant pairs.
e2e/soak/README.md, new gate 4: after a svc roll, no503/NCon the QUIC destination (LogsQL). The agent's dormant/republished lines per roll are included, as is the red reading. The soak: the churn set never starts a pod with a new ServiceAccount, so it is blind to the #1008 class — add a mid-run new-SA pod start and gate init_fetch_timeout on @ clusters #1014 new-SA step and the 18 svc rolls exercise it.e2e/soak/*.shis untouched.charts/andagent/internal/xds/proxy/{capture,egress,ingress}.goare not touched.Closes #1036
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr