Repository navigation
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
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
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
bpalermo
added a commit
that referenced
this pull request
Sep 28, 2026
…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.
Why
The first talos deploy of #1032 (rev245 = 1.0.2-6ad804b, 2026-09-28 03:00Z, an agent roll from an agent that had built SAs × destinations twins) logged this on every node:
observed_pairs == local_identities × 2everywhere. The demand scoping delivered no reduction, and because pairs prune only when their source leaves the node, the fan-out was persisted for good.Mechanism
On an agent restart the running Envoy opens a fresh delta stream and re-states its inventory in the stream's first CDS request. #1032's observer admitted a pair for every
quic:name in it:RestoreQUICTwinoninitial_resource_versions(the "held twins on a fresh xDS stream re-admit their pair" rule), andObserveQUICTwinonresource_names_subscribe. The twins the previous agent had built up front came back as observed pairs, and were persisted toObservedUpstreams.quic_pairs.One correction to the issue's proposed fix, found by the live gate
The issue proposed answering every re-stated twin the agent does not serve as absent, on the assumption that Envoy drops it and issues a fresh on-demand request the next time a route selects it. The pinned proxy does that for one kind of re-stated twin and not for the other:
removed_resources. The next routed request opens an ODCDS subscription and gets 200 over HTTP/3 in 23.7 ms. The issue's assumption holds.XdstpOdcdsSubscriptionsManager(od_cds_api_impl.cc) keeps one singleton subscription per name for the life of the process. On a removal it drops the cluster and keeps the subscription. Every later on-demand request for that name logsODCDS-manager: resource quic:… is already subscribed to, skippingand sends nothing. So answering such a twin absent strands the pair: every request from it 503sNCat the 2 son_demandtimeout until the proxy restarts. The strand control shows this live (status=503 … in 2.000384001s, with no CDS request reaching the control plane).So the rule splits by what the proxy says it has:
initial_resource_versionsonly (held-only)removed_resources) and the proxy drops itresource_names_subscribeon the stream's first CDS request (re-subscribed)ResumeQUICSubscriptions) and marked fetchedon_demandfilter, i.e. real first useObserveQUICTwin), refusals countedThe talos shape is the first row. rev245's twins came from the up-front build, which is wildcard-delivered, so under this PR they admit nothing. The second row is the only safe answer for a subscribed name.
Fix
agent/internal/xds/quicdemand(new) holds the classifier above. It lives in its own package so//test/mtlspoolruns the agent's classification instead of a copy of it.server/odcds.go:RestoreQUICTwinis gone. Heldquic:names no longer restore anything.ObserveQUICTwin. Re-stated names go torestateTwins, which logs one line per fresh stream:fresh xDS stream re-stated QUIC twins: … resubscribed=R resumed_pairs=P held_only=H held_served=S answered_absent=A.initial_resource_versions, so a held twin missing from the snapshot goes out inremoved_resourceson the first response.Prune rule and flag (migration for pairs already persisted on talos)
--east-west-quic-pair-fetch-window(default1h,0disables) drops a persisted pair once the window has elapsed since the agent started, if the pair had neither:The twin is dropped with the pair. The check runs on the refresher's one-minute prune tick. It logs one line per node:
Why this rule:
observed_pairsshould fall to the traffic pairs one window after the new agent starts.pruneQUICPairsLocked's removal-evidence pruning (source left the node, destination delisted or left the dependency set) is unchanged.#1032's guarantees, kept
TestOnDemandQUICTwinPerPair: 25.8 ms / 19.3 ms / 1.2 ms repeat.TestQUICDemandPairSurvivesAgentRestartis unchanged.TestQUICDemandPrunesWhenSourceLeavesOrDestinationIsDelistedpasses.Gates, each seen red
Red for the #1033 gates was produced by putting #1032's rule back in the shared classifier: held-only names were classified as re-subscribed, which admits them. That is exactly
RestoreQUICTwin. The unit and live gates both run that classifier.1. Server unit test, real delta server (
server/quic_restate_test.go,TestOnDemandObserver_FreshStreamHeldTwinsAdmitNothing). The setup is the agent's real observer and realSnapshotCachebehind go-control-plane's delta server, over bufconn: 12 local SAs × 2 QUIC destinations, an empty persisted set, and a first request holding 24 twins.admitted=0 answered_absent=24. A later request naming one twin admits exactly that pair.fresh stream: proxy holds 24 twins; admitted=24 answered_absent=24→Should be empty, but was [quic:echo…@demo/sa-00 …].…FreshStreamResubscribedTwinsAreServed: re-subscribed pairs are admitted, while held-only ones and a non-local source are not.2. Cache unit test (
TestQUICDemandPrunesPersistedPairsNotFetchedWithinTheWindow). Three persisted pairs: b is fetched on demand, c is re-subscribed, and a is neither.expected [source-b source-c], actual [source-a source-b source-c].3. Live (
//test/mtlspool, delta ADS, pinned proxy, real HTTP/3 destination requiring the client certificate).restartAgentstops the control plane and starts a fresh one on the same socket with an empty demand set, while the proxy keeps running.TestOnDemandQUICHeldTwinsNotReadmittedAfterAgentRestartcovers the talos shape: twins A and B are built up front, then the control plane restarts.TestOnDemandQUICSubscribedTwinsServedAfterAgentRestartcovers twins that were fetched on demand, then the control plane restarts.resubscribed=[A B]→ both re-published →source-a after the restart: status=200 proto="HTTP/3.0" in 7.3ms.source-a …: status=503 … in 2.000384001s, and no CDS request ever reaches the control plane. This control is the evidence for serving re-subscriptions.TestOnDemandQUICTwinRefusedFails, the negative control, is unchanged and passes.Runs
bazel … test --disk_cache= --test_output=errors //agent/... //test/...: 39/39 pass.--config=race //agent/internal/xds/...: clean.build --config=lint --@aspect_rules_lint//lint:fail_on_violation //agent/... //test/...: clean.//:formatand//:gazellewere run.Docs
docs/runbook.md:observed_pairsshould read on a healthy node (≈ pairs with traffic, single digits on talos;== local_identities × 2is the quic: demand-scoped twins re-admit every pair from Envoy's stream-reset re-subscriptions — observed_pairs == SAs × destinations on all talos nodes after the #1032 deploy #1033 red reading, with rev245's numbers);e2e/soak/README.mdgate 3:N == PandP ≪ I × S, with rev245's numbers as the red reading;docs/configuration.md: the new flag. It is not exposed in the chart;charts/is untouched.Follow-up (not fixed here)
The same Envoy behaviour affects #1032's removal-evidence pruning. Suppose a pair whose twin was fetched on demand is pruned because its source's last pod left the node, and a pod of that ServiceAccount later returns to the same node while the proxy lives. The twin is then stranded: the arm names a subscribed name that Envoy will not re-request. The same applies when a destination is delisted and re-listed. This is inferred from the mechanism the strand control demonstrates and was not reproduced separately. Filed as #1036.
Closes #1033
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr