Repository navigation
feat(quic): build a twin only for a (source SA, destination) pair that has dialled — the matcher arm names the twin, on-demand CDS fetches it on first use, pairs persist in ObservedUpstreams (#1020) - #1032
Merged
Conversation
…t has dialled — on-demand CDS from the matcher's on_no_match, persisted in ObservedUpstreams (#1020) The agent built one `quic:` twin per local ServiceAccount for every allow-listed destination up front: 118 on rev242, 2 of which ever carried a request (#1006). Unconditional QUIC (#979) would make that ~650. Now the selection route keeps one arm per local ServiceAccount, but the twin behind an arm is built only once that pair dials. The first request resolves through the matcher cluster-specifier to the missing twin; the HCM's on_demand filter asks for it by name over ODCDS; the agent's observer validates it (destination QUIC-enabled and in the dependency set, source a local ServiceAccount), records the pair in ObservedUpstreams.quic_pairs and publishes the twin with its own load assignment in one snapshot (#1008's rule, now load-bearing for every twin). A refused or timed-out fetch is 503 NC at the on_demand timeout (2 s); Envoy has no per-route fallback to h2 from an on-demand miss. Pairs have no idle TTL; they are pruned when the source leaves the node or the destination leaves the allow-list or the dependency set. - proxy: ParseQUICClusterName / IsQUICClusterName; OnDemandHTTPFilter exported for the live harnesses. - cache: quicPairs (depMu, persisted), ObserveQUICTwin / RestoreQUICTwin, armsFor (all local SAs) vs twinsFor (observed pairs), snapshot-time prune. - server: the ODCDS observer routes quic: names to the cache, re-admits held twins on a fresh stream, counts refusals (aether.agent.quic.twin.refused). - api: ObservedUpstreams.quic_pairs (edition 2024, implicit presence). - tests: cache gates (a)-(e), mtlspool live ODCDS gate + negative control, envoy_validate fixture with an unbuilt arm + on_demand, e2e E4c pair count. - docs: 038 Phase 4b + Selection, runbook, soak README. Co-Authored-By: Claude Opus 5.5 (1M context) <[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 28, 2026
…set re-subscriptions are answered absent, and stale persisted pairs are pruned (#1033) (#1035) 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 Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
bpalermo
added a commit
that referenced
this pull request
Sep 28, 2026
…ormant while its source or destination is away, republished on return, pruned only when the subscription is gone (#1036) (#1038) * fix(quic): a twin pair is admitted only on real first use — stream-reset 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 * 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) 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 * test(cache): drain the debounced observed-set write before t.TempDir 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 --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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
bpalermo
added a commit
that referenced
this pull request
Sep 30, 2026
…holds — agent-only restarts no longer drop live twins an hour later (#1073) (#1076) After a proxy restart every quic: twin reaches the new generation through the wildcard, with no on-demand fetch and no subscription, and carries its traffic that way. An agent-only roll then re-states those twins on the fresh stream as held-only, and the fetch-window prune ("no on-demand fetch since agent start") removed every one of them one window later: ~200 x 503 NC per burst fleet-wide on the #979 proving soak, and an Envoy SIGBUS on one node (#1074). A pair is now kept on any evidence of use, ever: a live stream's on-demand subscription (the ledger), or a confirmation -- fetched, re-subscribed, or its twin re-stated as HELD on a fresh stream while the agent serves it (ConfirmHeldQUICTwins). The confirmation is persisted (ObservedQUICPair.demand_confirmed), so a node reboot, where the fresh proxy uses twins it never fetches, does not prune them either. The window still drains pairs no generation vouched for (the #1032 fan-out, pre-#1073 pairs the proxy neither holds nor fetches). Closes #1073 Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Opus 5.5 <[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.
Why
The #1006 attribution found that on rev242 the fleet carried 118
quic:twins (59 local ServiceAccounts × 2 destinations), and only 2 of them ever carried a request (…@aether-test/default). An idle twin costs about 0 CPU. It does cost about 223 KiB of Envoy heap and about 52 stat series, and it is one more CDS resource to push, warm and keep in sync. It is also the surface of #1008. With unconditional QUIC (#979) the count would be about 650 twins, ~34k series and ~140 MiB of fixed heap fleet-wide. This PR builds a twin only for a (source ServiceAccount, destination) pair that has actually dialled. On today's fleet that is 118 → about 10.Mechanism
A note on the title's wording:
on_no_matchis unchanged and still names the h2 cluster. What triggers ODCDS is the arm. The two designs sketched in the issue cannot be expressed in Envoy's config API:ClusterAction { string cluster }, a static name and nothing else (matcher_cluster_specifier.cc). Soon_no_matchcannot formatquic:%REQ(:authority)%@%FILTER_STATE(...)%.cluster_headerreads a request header at routing time, and nothing can copy filter state into a header before routing.What does work:
Every local ServiceAccount keeps its arm (
aether.source.spiffe_id→quic:<svc>.<ns>.<domain>@<ns>/<sa>), exactly as today.on_no_matchis still the h2 cluster, for unstamped connections. The route tables do not change when a pair is observed, so there is no RDS push per new pair.The twin behind an arm is built only for an observed pair. A source's first request resolves through the matcher to a cluster the proxy does not have. The HCM's
on_demandfilter, which is already on every node-proxy HCM for fix(capture): on-demand catch-all + default mesh-DNS/capture on #288, asks for that name over ODCDS:on_demand_update.cccallsentry->clusterName()on the plugin's route entry.The agent's ODCDS observer (
server/odcds.go) sendsquic:names tocache.ObserveQUICTwin. That call:proxy.ParseQUICClusterName, the exact inverse ofQUICClusterName);ObservedUpstreams.quic_pairs(new proto field; edition 2024, implicit presence);The twin and its
LoadAssignmentAliasland in one snapshot. The fix(quic): give every twin cluster its own EDS resource name so a twin added after its base is not deduplicated into 15 s of warming (503/NC) (#1008) #1012/fix(xds): port-alias and TCP-floor clusters get their own EDS resource name, so a later-added one is not deduplicated into 15 s of warming (#1013) #1029 own-EDS-name rule is kept, and it is now load-bearing for every twin, because every on-demand twin is a late twin.Held twins on a fresh stream (
initial_resource_versions) re-admit their pair, the QUIC counterpart of demand-scoped TTL expires under continuous load and ODCDS re-discovery stalls ~5 min: 5-minute per-node outages on nodes with no local replica, invisible to soaks #682'sRestoreDependency.noteQUICFanoutis kept and now logsquic_clusters=N observed_pairs=P local_identities=I allow_listed_services=S.The allow-list flag semantics are unchanged.
The
aether.source.sastamp the issue suggested is not needed: the existing SPIFFE-ID stamp is the matcher key, and the arm carries the SA.First-request cost and failure mode
NCat theon_demandtimeout. That timeout stays at 2 s (onDemandClusterTimeout, the catch-all's value). A fallback to h2 on ODCDS failure cannot be expressed in Envoy: there is no per-route fallback from an on-demand miss, andOnDemandCdshas only the timeout. This is the same exposure the mesh catch-all has today, including an agent that is down while a new pair dials (demand-scoped TTL expires under continuous load and ODCDS re-discovery stalls ~5 min: 5-minute per-node outages on nodes with no local replica, invisible to soaks #682).aether.agent.quic.twin.refused{reason}. The proxy-side signal isenvoy_cluster_manager_odcds_init_fetch_timeout_total. Both are in the runbook.Pruning
There is no idle expiry, because nothing in xDS tells the agent that a twin stopped carrying traffic. A pair is pruned only on evidence that it is gone:
LoadListenersFromStorage), so a restore that runs first cannot prune everything;Pruning runs in the snapshot path, so a pruned pair's twin leaves in the same push. The persisted file is rewritten to match.
Gates, each seen red first
1. Cache unit tests (
agent/internal/xds/cache/quic_demand_test.go, plus the three existing QUIC tests updated to observe their pairs):on_no_matchis h2.ObserveQUICTwin(quic:…@demo/source-b)builds exactly that twin and its CLA in the same snapshot, with the arm present. A repeat request returnsKnown.quic_pairs), and a restarted cache builds the twin in its first snapshot.RemovePodof source-b drops its twin, CLA, arm and persisted pair. Delisting the destination drops the rest.:port, a foreign domain, an extra segment or a missing source: all refused, nothing recorded, CDS unchanged.Plus a restored pair that waits for the pod set before it is pruned,
TestParseQUICClusterName, and an observer test inserver.Red: with
twinsForput back to the pre-#1020 rule (every local SA × allow-listed destination), (a)–(e) all fail. For example, (a) readsShould be empty, but was [quic:…@demo/source-a quic:…@demo/source-b quic:…@demo/source-c].2. Live (
//test/mtlspoolquic_odcds_test.go, delta ADS, pinned proxy, a real HTTP/3 destination that requires and reports the client certificate; the harness's control-plane hook plays the agent's observer):TestOnDemandQUICTwinRefusedFailsis the kept negative control. Red: with theon_demandfilter removed from the source HCM, the green test fails withstatus=503 in 1.18ms. That shows the ODCDS path is what turns the arm into a 200.3.
//test/envoy_validate: the QUIC fixture now carries arms for sources a, b and c, twins only for the observed a and b, and production'son_demandfilter ahead of the router.envoy --mode validateaccepts it (quic_outbound_bootstrap.json ... OK). The pinned-TLS QUIC unwrap tests and the "no route to aquic:cluster sets early_data" assertion are unchanged and still pass. Red: building c's twin up front (the pre-#1020 shape) failsTestQUICOutboundFixtureCarriesTheSelection:twin "quic:echo.demo.mesh.local@demo/source-c" for an unobserved pair is built; it must be fetched on demand.4.
e2e/eastwest-quic.shon kind:quic:cluster count must equal the pairs driven over a selecting route, and the set must match exactly.Result:
Agent log from the run:
east-west QUIC fan-out quic_clusters=6 observed_pairs=6 local_identities=7 allow_listed_services=4. The pre-#1020 agent would have built 7 × 4 = 28 twins on that node. Red:EWQ_EXPECT_TWINS=28 e2e/eastwest-quic.sh verifyfails E4c with6 quic: clusters on the node, want 28. The EASTWEST_QUIC=off red now shows at E2 rather than E1; the header documents this. The kind cluster was torn down andkubectl config current-contextwas restored totalos-main.Runs:
bazel test //agent/... //test/...: all pass.--config=race //agent/internal/xds/...: clean.--config=lint --@aspect_rules_lint//lint:fail_on_violation //agent/... //test/... //api/... //e2e/...: clean. This needed a gocognit split inresumeHeldClusters.//:formatand gazelle were run.Docs
docs/runbook.md: how to read twin count against pairs;envoy_cluster_manager_active_clustersshould stay flat except +1 per new pair; the first-request failure mode withenvoy_cluster_manager_odcds_init_fetch_timeout_totalandaether_agent_quic_twin_refused_total; the ~2 s NC (ODCDS) versus ~15 s NC (QUIC: a twin cluster added after its base is subscribed never receives EDS (delta WatchMap dedup on the shared EDS name) — 15 s of 503/NC for every new ServiceAccount on a node #1008) distinction.e2e/soak/README.md: gate 3, twin count = observed pairs. 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 now also proves the ODCDS path: its first request must be 200 with no NC.docs/configuration.md: the allow-list's cost wording.Charts: no change needed.
agent.eastWestQuicServiceskeeps its meaning; only the cost it implies drops.Closes #1020
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr