Skip to content

fix(agent): the xDS ACK tracker keeps what a proxy holds per stream, a listener wait is for the published version, and nothing known is not a listener absent (#1624) - #1632

Merged
bpalermo merged 5 commits into
mainfrom
fix/1624-ack-tracker-per-stream
Oct 10, 2026

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Closes #1624

What is now true

The ACK tracker (agent/internal/xds/ack) keeps what a proxy holds per xDS stream. A stream is one connection of one proxy process: a hot restart has two for a while, and a proxy that reconnects opens a new one.

The two waits the CNI server makes:

wait answered when failed when
WaitListenerPresent (pod ADD) one proxy holds the listener at the version the agent publishes now, with nothing that adds or removes the name unanswered on its stream any connected proxy's last answer about the name is a rejection of the published version
WaitListenerAbsent (pod DEL) there is a proxy that has asked for its listeners, and every such proxy is known not to hold the listener: its statement has been answered, the name is not held, nothing about it is unanswered, and its last answer about it was not the rejection of an add never by a rejection (see below)

The published version is read from the snapshot cache (ack.SnapshotVersions, wired in agent/internal/cmd/root.go).

Choices this makes, and why

  • Absent: every generation. Each generation of a hot restart has its own sockets in the pod's network namespace.
  • Present: one generation answers, either rejecting fails. This is a choice, not a proof that the listener serves; see the first limit under Not settled.
  • A proxy is known from the moment its statement is answered, not from the statement. The answer was computed from the snapshot of a moment before and can add the very listener a DEL has just removed. Written, that response is in flight and holds the wait; between the statement and the response nothing would.
  • An ADS stream counts from its Listener request, not from its opening (changed in review). A new generation loading its clusters holds no listener, and counting it cost the full wait and a false failure on every pod DEL of every hot restart. What is given up is the moment between a reconnecting proxy's stream opening and its Listener request, which is shorter than the time its stream was closed, when nothing was known of it either.
  • A rejected response is read for what the proxy does with it, measured on the pinned proxy: it does every removal before any add and rejects at the end, and it keeps the listeners it could build. So what a rejected response removed is gone (TestRemovalCarriedByARejectedResponseIsDone), and what it added is not read as absent (TestRejectedListenerResponseIsAppliedInPart).
  • Holdings are kept for the Listener type only, the one type somebody waits on.

What it costs (the decision #1572 named)

A managed pod DEL (and ADD) that arrives while no proxy has asked for its listeners takes the full wait (envoyAckTimeout, 2 s) and then proceeds: after an agent restart until the proxy has reconnected, and whenever the proxy is down. The DEL used to return at once.

Those are counted apart: aether_agent_xds_ack_wait_failures_total{reason="no_proxy"}. reason="timeout" now means there was a proxy to ask and it did not answer in time. The counter's series set changes from four to five: present × nack/timeout/no_proxy, absent × timeout/no_proxy. absent/nack is gone, because no rejection fails a removal wait any more. The reason set is not in test/harnesscontract/external-harness.yaml (that file's reason sets are the pin metrics'), so the contract is unchanged. docs/runbook.md has the reading.

Settled, and the test that shows it

Every test below failed against the unchanged tracker first (with a shim for the two new names), unless marked guard.

issue settled test
#1624 a wait is for the published version, not a name yes TestWaitListenerPresent_IsForThePublishedVersion, TestWaitListenerPresent_ARejectionIsOfAVersion, TestServer_ReturnToAnAcknowledgedVersion, TestAckTrackerReadsThePublishedListenerVersionFromTheCache (the real cache)
#1511 a proxy that states the published version answers the wait yes TestWaitListenerPresent_AnsweredByWhatTheProxyStates, TestServer_StatedAtThePublishedVersionAnswersTheWait (real go-control-plane), TestReconnectingProxyStatesTheListenersItHolds (real proxy)
#1572 unknown is not absent yes, at the cost above TestWaitListenerAbsent_UnknownIsNotAbsent, TestWaitListenerAbsent_KnownFromTheFirstResponse, TestServer_StatedButNotPublishedIsRemoved, TestRemovePod_WaitsUntilAProxySaysWhatItHolds (the CNI server; each of its two waits pinned alone)
#1585 state is dropped with its stream yes TestStreamClose_ForgetsWhatItsProxyHeld, TestServer_StreamReset
#1573 a removed name is forgotten yes: a removal forgets the name whether the response that carried it was acknowledged or rejected. What stays under a name is a rejected add, until the name is removed, added again, or the stream closes TestTrackerForgetsARemovedListener (against the unchanged tracker it fails already at its fixture, which also counts what is kept for clusters; the mutation that keeps a removed name is killed by it), TestNack_TheRemovalsOfARejectedResponseAreDone
#1574 an ACK is matched on type as well as nonce yes TestAck_ANonceEchoedUnderAnotherTypeAnswersNothing
#1624 no answer from one generation can erase another's yes TestTwoGenerations_NoAnswerOfOneErasesTheOthers (three of five cases failed before; the other two are guards), TestTwoGenerations_WhichMustHoldTheListener, TestServer_TwoGenerationsRemoveAListener

Mutation check: 34 mutations of tracker.go (each condition of the two decisions, the type check, the close, the straggler mark, every wake-up, the NACK reading, the expiry reason), each killed by at least one test; and the two waits of RemovePod in pod.go, each dropped in turn, each killed by its own sub-case.

Not settled (each pinned by a test that asserts what happens)

  • An answered ADD wait is not proof of a serving listener during a hot-restart overlap. A proxy that has stopped its listeners (the parent, once the child has taken over) acknowledges a listener it does not add; the tracker sees only the ACK and reads it as held, and one proxy holding the listener answers the wait (TestADrainingProxyAcknowledgesAListenerItDoesNotAdd, measured with the admin endpoint that makes the same call). Nothing on the stream tells a draining proxy from a serving one. The CNI plugin's in-netns probe stays the proof.
  • A listener the proxy kept from a rejected response is not in its statement when it reconnects (TestListenerOfARejectedResponseIsNotStatedAtReconnect). After an agent restart the agent has no word of it: a DEL is not waited for, and if its pod is gone nothing ever removes it from the proxy.
  • A response computed and not yet written is invisible (TestServer_AbsentReturnsWhileAnAddIsOwedToTheProxy, not timed: the stream's goroutine is held). A DEL that lands between the cache computing a response that adds the listener and the stream writing it returns before that response is seen. Same window as before this change; closing it needs the cache's order.
  • A generation whose stream reset during a hot-restart overlap is unknown from its close until its next Listener request. Meanwhile the other generation alone answers.
  • A same-named replacement pod published before its predecessor's DEL waits: the name is never removed, so that DEL's wait runs to its bound. Unchanged.

From #1559

Carried, adapted to the model: the real go-control-plane harness and its tests, the cache tests, the real-proxy LDS test, the version, rejection, unanswered-response, two-generation and concurrency cases. Not carried, because they describe that design and not wanted behaviour: a statement that answers nothing until the opening response is acknowledged, a rejected opening response that "resolves nothing", reading the opening exchange only for a plain wildcard subscription, the send-order cases, and the unwired tracker failing on any rejection.

Changed tests on main: TestWaitListenerAbsent's first case ("never-known listener is absent immediately", with no proxy) now asserts the opposite, which is #1572; TestMetrics_WaitFailures' timeout case and TestMetrics_WaitFailuresSeeded follow the new reason set; the test helper ackDelta answers under the type of the response it answers; three white-box assertions follow the new fields. No case was removed.

Outside the tracker

  • agent/internal/cni/server/pod.go is not touched: the call sites keep their signatures. pod_test.go gives the unit-test server a tracker that has seen one proxy holding nothing, so its DELs still return at once.
  • agent/internal/xds/cache/listener.go and podnames.go are not touched.

Verification

  • bazel test --config=race on //agent/internal/xds/ack:ack_test, //agent/internal/xds/cache:cache_test, //agent/internal/xds/server:server_test, //agent/internal/cni/server:server_test, //agent/internal/cmd:cmd_test, //agent/test/mtlspool:mtlspool_test: pass, after merging main.
  • bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...: clean. make format-check: clean.
  • Not verified: no cluster run. The cost above is derived from the code and the tests, not measured on a node.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…a listener wait is for the published version, and nothing known is not a listener absent (#1624)

The tracker kept one state per listener name, shared by every xDS stream.
With two proxy generations connected, or a reconnect, answers from different
streams interleaved, and what the last one to arrive said stood.

It now keeps, per stream, what the proxy on it holds: what the proxy stated
in its first Listener request, with every response it acknowledged since,
applied in the order it acknowledged them. A stream is one proxy process, so
that is the proxy's own history and needs no ordering between streams.
Everything goes with the stream when it closes. What the node holds is read
off the open streams when a wait asks.

- WaitListenerPresent is for the version the agent publishes, read from the
  snapshot cache. One connected proxy holding it, with nothing unanswered
  about the name, answers the wait; any connected proxy rejecting that
  version fails it. A proxy that states the published version when it
  reconnects answers it (#1511).
- WaitListenerAbsent is for every connected proxy to be known not to hold
  the listener. A proxy is not known before its first Listener request is
  answered, and nothing is known with no proxy connected (#1572). A rejected
  add is not read as absent: the pinned proxy applies a rejected Listener
  response in part (measured, //agent/test/mtlspool).
- A stream's state is dropped with it, so a new Envoy process starts unknown
  (#1585), and an acknowledged removal forgets the name (#1573).
- An ACK answers a response of its own stream and its own type (#1574).

A pod DEL that arrives with no proxy connected, or while a new proxy
generation has not asked for its listeners yet, now takes the full wait
(2 s) where it used to return at once.

Closes #1624

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo and others added 4 commits October 10, 2026 06:43
…est, a removal carried by a rejected response is done, and a wait with no proxy to ask is counted apart (#1624)

Review of the per-stream tracker:

- An ADS stream that has not asked for its listeners no longer holds a pod
  DEL: a new generation loading its clusters holds no listener, and counting
  it cost the full wait on every DEL of every hot restart.
- The proxy does every removal of a Listener response before any add and
  rejects the response at the end (measured, //agent/test/mtlspool). A NACK
  is now a rejection of the adds only; what the response removed is gone and
  forgotten, so no rejection fails a removal wait and there is no
  absent/nack series.
- A wait that ends with no proxy to ask is counted under reason no_proxy,
  not timeout.
- Pinned as limits, with the comments corrected: a proxy that has stopped
  its listeners acknowledges a listener it does not add, so an answered ADD
  wait is not proof of a serving listener in a hot-restart overlap; and a
  response computed but not written is invisible to the tracker.
- Tests: each of RemovePod's two waits is pinned alone, and a proxy that
  arrives while a wait looks is seen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 9a89928 into main Oct 10, 2026
30 checks passed
@bpalermo
bpalermo deleted the fix/1624-ack-tracker-per-stream branch October 10, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agent: keep the xDS ACK tracker's listener state per stream instead of one state per name

1 participant