Repository navigation
fix(xds): a restarted agent's proxy hears drain marks within 1 s of the agent serving, without dropping its quic: twins; cross-replica drain marks skip the write-behind tick (#1103) - #1118
Merged
Conversation
…started agent's drain marks reach it promptly (#1103) While the ADS stream to the node agent is down the proxy routes on its last config, so a destination marked DRAINING in the meantime is still selected. Envoy's xDS default (fully jittered, 500 ms base, 30 s cap) left main-worker-04's proxy reconnecting 8.4 s after its restarted agent was serving again on 2026-10-01; it sent three requests to a pod drained 3.4 s earlier. retry_back_off {0.1s, 1s} bounds that tail to < 1 s. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
… certificates are in the snapshot (#1103) A restarted agent served its first snapshot before the SPIRE bridge had re-delivered the pods' certificates, so the #1049 gate left every quic: twin out of it. A proxy reconnecting to that snapshot is told to remove the twins it holds and routes into the gap until the certificate's snapshot re-adds them: on kind, 1-9.6 s of cluster_not_found per restart, 56 x 503 in one. Envoy's 30 s reconnect backoff hid it most of the time; the 1 s cap makes it the common case. PreListen now waits (bounded, 5 s) for the snapshot to carry every local certificate. Also: e2e/drain-propagation.sh (kind proof) and the runbook entry. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…he next write-behind tick (#1103) A peer registrar replica sees an endpoint change only once the external registry holds it. Waiting for the 500 ms tick put up to half a second into every cross-replica drain mark (0.5-0.9 s mark -> last request on kind, against 0.2 s when both agents share a replica). Enqueue now kicks the flush loop; the ticker keeps driving retries. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…1103) Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…ation Chart version 2.1.1 (main is 2.1.0); runbook keeps both #1103 and #1104. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Oct 1, 2026
bpalermo
added a commit
that referenced
this pull request
Oct 2, 2026
…t serves its node proxy (#1123) (#1135) * fix(agent): an agent restart stops waiting out retry ladders before it serves its node proxy (#1123) The node proxy has no ADS stream from the old agent's exit until the new one serves xDS. Measured on kind (e2e/agent-restart-gap.sh, proxy-side control_plane.connected_state, 2 nodes, etcd backend): median 12.0 s / p99 17.9 s on main (n=16), median 5.5 s / p99 8.8 s on this branch (n=20). Startup, after the agent's own SVID, drops from ~6 s to ~0.1 s: - The registrar client's post-identity reconnect waits for the ClientConn to be READY instead of sleeping a whole 1 s backoff after the wake's first retry lost the redial race (the steady ~1.05 s on every talos node). - The SPIRE bridge's pod subscriptions retry the moment the agent's own SVID is served (with the broker connection's backoff reset) instead of on their 1 s+ doubling ladder; on main the client-certificate first-serve gate of #1118 hit its 5 s bound in 7 of 16 kind restarts. - Every Workload API source retries 200 ms / 400 ms / then every 500 ms instead of go-spiffe's linear whole-second ladder. - PreListen builds the local listeners from storage during the identity hold (the socket still opens only after identity, capture projection, registry load and client certificates); the #877 TCP-floor WARN gets a 1 min startup grace with SPIRE on so this does not log on every restart. Pod replacement: - agent and cni-install images default to IfNotPresent (digest-pinned; the kubelet counted 1.44 s of image checks on one talos restart). - cni-install leaves an identical plugin binary, conflist and durable entry alone instead of rewriting and fsyncing them on every pod start. - Readiness probed every 2 s from the start (Ready ~1 s after container start instead of ~10 s), failureThreshold 15 keeps 30 s to NotReady. The remaining terms (pod replacement 2.8-3.4 s on kind, the SPIRE first SVID 1-5 s on kind / 0.15-2 s on talos) are not the agent's to remove; proposal 041 designs the surge roll with a standby agent that removes both. Chart 2.2.0 -> 2.2.1. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * fix(spire): drop the broker ClientConn backoff reset that races grpc-go's subchannel map; redial on a 250 ms cap instead (#1123) grpc-go's ClientConn.ResetConnectBackoff copies the map reference under cc.mu and iterates it after unlocking, so it races newAddrConnLocked writing the same map (the race job on #1135: TestBridgeSurvivesSubscribeFailures, 12 of 20 local runs). The broker connection is node-local; it now redials on a 50 ms base / 250 ms cap backoff, which bounds how long WaitReady takes after the agent's SVID lands without touching the ClientConn's internals. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * chore(chart): aether 2.2.2 (above main's 2.2.1) (#1123) Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr --------- Co-authored-by: Claude Fable 5.1 <[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.
Refs #1103
Finding: the source proxies had no ADS stream
The drain mark propagates quickly. In both 2026-10-01 TRIPLE instances the source node agent was restarting at the time, so the source proxy had no ADS stream to its agent and kept routing on stale config. The issue said "the same happens with the source agent up". That does not hold for these two: both source agents were mid-restart. Read-only VictoriaLogs, agent/registrar/proxy streams:
sync detected changesThe answers to the questions in the issue:
PreListenholds the socket until the registry load succeeds. The 3.5 s wait on w04 is that hold, and the snapshot it served carried the mark.DRAINING. An EDSDRAININGhost is excluded from new selections at the pinned Envoy:upstream_impl.cc:699-719(setEdsHealthFlagsetsEDS_STATUS_DRAINING), andupstream_impl.cc:1878-1882(excludeBasedOnHealthFlagputs it in the excluded set).healthy_panic_threshold: 0means panic routing never re-selects it. Nothing ever selects it once the update is applied, so the update arriving is the whole problem.xds_manager_impl.cc:202-205RetryInitialDelayMs/RetryMaxDelayMs;backoff_strategy.cc:13-19returnsrandom() % intervaland doubles the interval). The longer the agent was down, the longer the proxy waits after the agent comes back.Fix (three parts, ship together)
ads_config.grpc_services[0].envoy_grpc.retry_policy.retry_back_off {base_interval: 0.1s, max_interval: 1s}(charts/aether/templates/agent-proxy-configmap.yaml). The proxy now reconnects within 1 s of the agent's socket opening, however long the agent was away. Each failed attempt is aconnect()to a local unix socket that does not exist yet.quic:twin out of it, and the reconnecting proxy is told to remove the twins it holds (cds: ... 0 added/updated, 1 removed,remove cluster 'quic:quic-a...@aether-test/client-a'). Routes keep selecting the twin until the certificate's snapshot re-adds it.PreListennow waits, bounded at 5 s, untilSnapshotCache.AwaitingClientCertificates() == 0. This is node agent only (identity gate set).wbTickbefore the external registry (and therefore the peer replica's watch) saw it. This was the cross-replica steady-state term: on kind, mark → last request was 0.5–0.9 s cross-replica against 0.2 s same-replica. The ticker still drives retries and backoff.Docs: new runbook section "A source keeps picking an endpoint seconds after its drain mark (#1103)".
Evidence
Unit tests (seen red, then green):
//test/envoy_validateTestNodeProxyADSReconnectBackoffIsBoundedreads the chart'sretry_back_off, asserts the cap is ≤ 1 s, and runsenvoy --mode validateon a bootstrap carrying it.ads_config carries no retry_policy.retry_back_off ... stays blind up to 30 s.//charts/aether:aether_proxy_bootstrap_ads_reconnect_backoff_test.//agent/internal/xds/serverTestPreListen_WaitsForLocalClientCertificates, plus bounded / no-gate / shutdown cases, run against the real cache: a local pod whose SVID has not arrived yet.PreListen returned ... while the snapshot still held 1 local identity out of east-west QUIC.//registrar/internal/serverTestWriteBehindFlushesANewIntentWithoutWaitingForTheTick.Condition never satisfied ... well inside one wbTick (500ms).kind red → green. The new harness is
e2e/drain-propagation.sh(clusteraether-1103):EWQ_WORKER=1shape, on the etcd registry backend as talos runs it, with 2 registrar replicas.quic-a×2 on the worker with a 15 s preStop sleep, so a deleted replica's app logs every request a source still sends it.client-aon the control plane.bootstrap main|fixrewrites the live ConfigMap and waits for the hot restart to load it (read back from the admin config dump);swap-agent; registrar image.The R gate (
DRP_EXPECT=green) asserts every reconnect is ≤ 1.5 s and that no CDS removal follows a reconnect. The S gate asserts every gap is ≤ 1 s.Two more observations:
Checks:
bazel testfor//agent/...,//registrar/internal/server:all,//agent/internal/xds/cache/...,//test/envoy_validate:all,//charts/aether:all: pass.--config=raceon//agent/internal/xds/server:all,//agent/internal/xds/cache:all,//registrar/internal/server:all,//test/envoy_validate:all: pass.make gazelle,make format, andbazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...: clean.What remains on #1103 (why this is
Refs)503 UF. In both TRIPLE cases the destination inbound spent 5 s (the default connect_timeout) connecting to127.0.0.1:8080in a pod whose app had exited. A refused connection would have been a fast, retriable 503 (retriable-status-codes[503]) that reached the source before CNI DEL. Why the SYN went unanswered was not established.DRAININGmark exists only on the replica that received it. Agents watching the other replica see the pod only through its Ready condition on the 5 s poll. Not measured here (kind ran etcd, like talos).Tonight's soak
Safe to ride, with the soak watching agent restarts. Parts 2 and 3 are small and covered by tests; part 2 costs 0 on talos per the 2026-10-01 timings. The bootstrap change hot-restarts every proxy once on deploy (the supervisor's ConfigMap watch), as any chart bootstrap change does. If the soak shows
remove cluster 'quic:...'right after an agent restart (proxy debug) orlocal workloads' client certificates not delivered in time(agent WARN), that is the part 2 bound being hit.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr