Repository navigation
fix(capture): a mesh-Service re-projection no longer strips the declared-port TCP chains, and the first serve waits for the projection (#1094) - #1099
Merged
Conversation
…red-port TCP chains, and the first serve waits for the projection (#1094) SetCaptureTCPServices rebuilt its entries from the capture reconciler's input alone (name, VIP, primary class) and dropped the endpoint-derived primaryPort and tcpPorts that only refreshCaptureTCPPorts (a registry load) fills in. equalTCPEntries then saw a change, so EVERY mesh-Service event rebuilt every capture listener without its destination_port chains until the next registry load. A snapshot pushed inside that window served connections to a declared port from the any-port shim (past proposal 037 Phase 4: from nothing), and the in-place update drained the connections on the removed chains. An agent restart interleaves one reconcile per mesh Service with its first registry loads, which is how talos hit it: on main-worker-03 a registry load derived the ports (05:41:54.950), the reconciler re-projected (05:41:55.054), snapshot .11 went out (05:41:55.081) and served tcp-echo:9000 from cap_tcp_anyport_* (05:41:55.436), and the next load put the chain back (05:41:55.979). The xDS socket had opened at 05:41:53.879, so this was a mid-life flap, not an incomplete first snapshot. Fix: the cache keeps the last derivation and SetCaptureTCPServices applies it, so the two halves of an entry compose in either order and an unchanged re-projection is not a change. Also close the first-serve gap the investigation exposed: nothing ordered the xDS socket opening after the reconciler's first projection (on talos the registry wait happened to outlast it). The cache now exposes CaptureProjected(), PreListen waits on it (bounded, 10 s) before the registry load whose snapshot the socket opens on, and the capture controller gets one synthetic event so a mesh with no Services still projects. kind (l4routes, single node), 32 bursts of 5 no-op mesh-Service updates under 4 dial loops to l4-a:9000: main: cap_tcp_anyport +138 / 1292 dials, listener_modified +556 branch: cap_tcp_anyport +0 / 1284 dials, listener_modified +0 Closes #1094 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Oct 1, 2026
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.
Closes #1094
Root cause
It was not an incomplete first snapshot. It was a mid-life flap that an agent restart makes dense.
SetCaptureTCPServices(agent/internal/xds/cache/capture.go:282, on main) built eachcaptureTCPEntryfrom the capture reconciler's input only: name, VIP andprimaryIsTCP. It droppedprimaryPortandtcpPorts. OnlyrefreshCaptureTCPPorts(capture.go:1323, called from a registry load atcluster.go:324) fills those two fields in. As a result:equalTCPEntries, because the derived fields went to zero.destination_portchains. That removes thecap_tcp_<svc>_<primary>chain and every non-primary per-port chain. The:18082andanyportchains stay.cap_tcp_anyport_*. After proposal 037 Phase 4 it would be served by nothing. The in-place LDS update also drains the connections on the removed chains.The capture reconciler runs once per mesh Service when its informer first lists them. After a restart those runs interleave with the first registry loads. From the w03 agent log (VictoriaLogs,
aether-agent-q6rxl):loaded clusters from registry(ports derived)projected mesh-Service authorities(ports wiped, listeners rebuilt)setting snapshot …11(the tail of that load, now chainless)10.96.11.228:9000served bycap_tcp_anyport_tcp:tcp-echo…loaded clustersrestores the chains, snapshot .12Fix
cache.go,capture.go). The cache keeps the last derivation (captureDerivedTCPPorts/captureDerivedPrimaryPorts) andSetCaptureTCPServicesapplies it.server.go,root.go,capture/reconciler.go). Nothing ordered the socket opening after the reconciler's first projection; on talos the registry wait happened to outlast it.CaptureProjected().PreListenwaits on it before the registry load whose snapshot the socket opens on. The wait is bounded at 10 s, returns nil on shutdown, and logs a WARN on timeout.source.Channel), so a mesh with no Services still projects and does not sit out the bound. The event goes through the controller's own workqueue so projections stay serialized.Evidence
Unit, red on main then green:
TestCaptureReprojectionKeepsDeclaredPortChains(cache)._9000/_9001chain. The identical-re-projection subtest also fails its byte-equality check.TestPreListen_HoldsUntilCaptureProjection/_CaptureGateIsBounded/_CaptureGateEndsOnShutdowncover the gate (server).TestInitialProjection_OneEventThatProjectsAnEmptyMeshcovers the synthetic event (capture).kind, red then green (
e2e/l4routes.sh up, clusteraether-1094, single node). Each run: 32 bursts of 5 no-op mesh-Service annotation updates, with 4 parallel dial loops tol4-a…:9000(TCP-primary, declared port). Counters were read from Envoy admin.cap_tcp_anyport_tcp:l4-a…cap_tcp_…l4-a…_9000listener_manager.listener_modifiedlistener_modifiedon both builds, the same count, so that is a restart artifact unrelated to this fix.mesh-Service projection received … waited=109msat startup, so the gate did hold the first serve in kind../e2e/l4routes.sh verifyon the branch passes: TCPRoute, TLSRoute and UDPRoute legs.Checks run:
bazel test //agent/...(non-integration): 43/43 pass.--config=raceonxds/cache,l4route,xds/server,capture: pass.make gazelle,make format, andbazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...: clean.Open risks / not in scope
anyportgate (docs(soak): raw-counter grading rule, fixed gate selectors, set-based #1009 rule, L4-log anyport gate, per-client DC baseline #1098) is the real check.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr