Skip to content

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
bpalermo merged 2 commits into
mainfrom
fix/quic-pairs-no-readmit
Sep 28, 2026

Conversation

@bpalermo

@bpalermo bpalermo commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

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:

east-west QUIC fan-out quic_clusters=24 observed_pairs=24 local_identities=12 allow_listed_services=2
                       18/18/9, 28/28/14, 20/20/10, 20/20/10

observed_pairs == local_identities × 2 everywhere. 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: RestoreQUICTwin on initial_resource_versions (the "held twins on a fresh xDS stream re-admit their pair" rule), and ObserveQUICTwin on resource_names_subscribe. The twins the previous agent had built up front came back as observed pairs, and were persisted to ObservedUpstreams.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:

  • Twin held only through the wildcard. Delivered by CDS, with no on-demand subscription behind it (this is how the pre-QUIC: build twins on observed demand only — 116 of 118 twins never carried traffic; ~223 KiB + ~52 series each; ~650 twins under unconditional QUIC #1020 agent's up-front twins arrived). The proxy drops it on 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.
  • Twin fetched on demand. Envoy's 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 logs ODCDS-manager: resource quic:… is already subscribed to, skipping and sends nothing. So answering such a twin absent strands the pair: every request from it 503s NC at the 2 s on_demand timeout 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:

Re-stated as Meaning Agent
initial_resource_versions only (held-only) a twin an older agent built; no request ever routed to it admits nothing. If the pair is not persisted, it is answered absent (removed_resources) and the proxy drops it
resource_names_subscribe on the stream's first CDS request (re-subscribed) a live ODCDS subscription that a routed request opened, and that Envoy will never re-send served if the pair is valid (ResumeQUICSubscriptions) and marked fetched
named on a later request, not held the on_demand filter, i.e. real first use admitted (ObserveQUICTwin), refusals counted

The 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/mtlspool runs the agent's classification instead of a copy of it.
  • server/odcds.go:
    • RestoreQUICTwin is gone. Held quic: names no longer restore anything.
    • First-use names go to ObserveQUICTwin. Re-stated names go to restateTwins, 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.
  • Answering absent needs no new code. go-control-plane seeds the stream's returned-resource map from initial_resource_versions, so a held twin missing from the snapshot goes out in removed_resources on the first response.
  • Persisted pairs are still restored before the first snapshot and remain the carry-over across agent restarts.

Prune rule and flag (migration for pairs already persisted on talos)

--east-west-quic-pair-fetch-window (default 1h, 0 disables) drops a persisted pair once the window has elapsed since the agent started, if the pair had neither:

  • an on-demand fetch in this process, nor
  • a re-subscription by the proxy on this agent's stream.

The twin is dropped with the pair. The check runs on the refresher's one-minute prune tick. It logs one line per node:

pruned persisted east-west QUIC pairs with no on-demand fetch since agent start count=N remaining=M window=1h0m0s pairs=[…]

Why this rule:

  • No traffic signal. The agent makes no admin calls, and a served twin is never fetched again. "Fetched since start" is the only evidence of use the agent can see.
  • Re-subscribed pairs are exempt. Pruning one would strand it (see above).
  • A pruned pair can only be held-only or new-proxy. The proxy therefore drops the cluster outright. A pruned pair that still carries traffic pays one ODCDS round trip (~20 ms, no 503) on its next request and is re-admitted. That is the whole cost of a wrong prune, and it happens once per agent start.
  • Talos after this deploys. Each node's observed_pairs should 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

  • First request of a new pair still rides QUIC over ODCDS with no 503. TestOnDemandQUICTwinPerPair: 25.8 ms / 19.3 ms / 1.2 ms repeat.
  • Pairs persist across restarts. TestQUICDemandPairSurvivesAgentRestart is unchanged.
  • SA/destination pruning is unchanged. TestQUICDemandPrunesWhenSourceLeavesOrDestinationIsDelisted passes.

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 real SnapshotCache behind 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.

  • Green: admitted=0 answered_absent=24. A later request naming one twin admits exactly that pair.
  • Red: fresh stream: proxy holds 24 twins; admitted=24 answered_absent=24 → Should be empty, but was [quic:echo…@demo/sa-00 …].
  • Companion test …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.

3. Live (//test/mtlspool, delta ADS, pinned proxy, real HTTP/3 destination requiring the client certificate). restartAgent stops the control plane and starts a fresh one on the same socket with an empty demand set, while the proxy keeps running.

TestOnDemandQUICHeldTwinsNotReadmittedAfterAgentRestart covers the talos shape: twins A and B are built up front, then the control plane restarts.

  • Green:
    [odcds] fresh stream 1 re-stated: resubscribed=[] held_only=[quic:…@demo/source-a quic:…@demo/source-b]
    after the restart, before any request: proxy holds [], published []
    [odcds] CDS subscribe quic:echo.demo.aether.internal@demo/source-a (admit=true)
    source-a first request after the restart: status=200 san=".../sa/source-a" proto="HTTP/3.0" in 23.662611ms
    --- PASS   (only A's twin exists; B's stays absent)
    
  • Red:
    after the restart, before any request: proxy holds [quic:…@demo/source-a quic:…@demo/source-b], published [… both …]
    only A's twin exists; B's stays absent: expected [source-a], actual [source-a source-b]
    

TestOnDemandQUICSubscribedTwinsServedAfterAgentRestart covers twins that were fetched on demand, then the control plane restarts.

  • served: resubscribed=[A B] → both re-published → source-a after the restart: status=200 proto="HTTP/3.0" in 7.3ms.
  • strand_control answers them absent, as the issue first proposed: 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.
  • //:format and //:gazelle were run.

Docs

  • docs/runbook.md:
  • 038 Selection paragraph: admission only on evidence of a routed request, the held vs re-subscribed split, and the prune window.
  • e2e/soak/README.md gate 3:
    • N == P and P ≪ I × S, with rev245's numbers as the red reading;
    • grade gate 3 after the one-hour prune line on a node carried over from rev245;
    • a per-pod read of the fan-out and prune lines.
  • 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

…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
@bpalermo bpalermo changed the title 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) 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) Sep 28, 2026
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
bpalermo merged commit c8f7df8 into main Sep 28, 2026
24 checks passed
@bpalermo
bpalermo deleted the fix/quic-pairs-no-readmit branch September 28, 2026 04:17
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant