Repository navigation
fix(agent): a listener ACK wait is for the version the agent publishes, and a proxy that states that version resolves it from the opening exchange (#1511) - #1559
Closed
bpalermo wants to merge 12 commits into
Conversation
…lves its ACK wait from the opening exchange (#1511) After an agent restart the proxy already holds every pod listener, so go-control-plane sends nothing for them on the new stream and nothing acknowledges them by name. WaitListenerPresent ran to its deadline for each, and WaitListenerAbsent returned at once because the new agent knew of no listener to wait for. The ACK tracker now keeps the names the first request of a type on a stream states in initial_resource_versions, and reads the first response of that type against them: a stated name the response neither adds nor removes was stated at exactly the version the snapshot publishes. Those names are marked present when the proxy ACKs that response. Nothing is concluded unless the request opens a wildcard subscription, it is the only request of the type before the first response, and the response is acknowledged on the same stream. A listener stated at another version is sent and resolved only by the proxy's answer to it; a rejected opening response resolves nothing. Measured on the pinned proxy in //agent/test/mtlspool (lds_reconnect_test.go) and against the real go-control-plane server in the ack package. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
There was a problem hiding this comment.
🟡 Changes recommended
A DEL racing the opening ACK can still bypass the listener-removal wait.
1 open finding
What changed in this PR
Updates ACK tracking so listeners retained across agent restarts can be recognized through the opening delta-xDS exchange.
Changes:
- Tracks resources stated in opening requests and marks them present after ACK.
- Adds unit, server, and pinned-proxy reconnect tests.
- Documents changed ACK-wait metrics behavior.
| File | Description |
|---|---|
agent/internal/xds/ack/tracker.go |
Implements opening-exchange tracking. |
agent/internal/xds/ack/stated_test.go |
Tests tracker semantics and edge cases. |
agent/internal/xds/ack/stated_server_test.go |
Tests against the delta server and cache. |
agent/internal/xds/ack/opening_test.go |
Extends stream-cleanup coverage. |
agent/internal/xds/ack/BUILD.bazel |
Registers new tests and dependencies. |
agent/test/mtlspool/lds_reconnect_test.go |
Verifies behavior with the pinned proxy. |
agent/test/mtlspool/BUILD.bazel |
Adds the reconnect test source. |
docs/runbook.md |
Documents restart and metric behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… absent until the opening response is acknowledged (#1511) Review: a DEL that arrives before the proxy has acknowledged its opening Listener response, or before any proxy has connected, is still not waited for. State that limit on WaitListenerAbsent and in the runbook, and hold it in the test instead of implying the wait is unconditional. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Oct 9, 2026
…ot for the name (#1511) Review of the first version of this change proved four cases where reading the opening exchange by the listener's name answered a wait wrongly. A pod's listeners are named after the pod, so a same-named replacement publishes other content under a name the proxy already holds, and "the proxy stated this name" (or, before this change, "the proxy once acknowledged this name") said nothing about the replacement. The tracker now records the version with the name: the version an acknowledged response carried, or the version the proxy stated. With a PublishedVersion (SetPublishedVersion, which the node agent wires to its snapshot cache through SnapshotVersions), WaitListenerPresent is answered only when that is the version published when the wait looks. Without one the tracker keys presence by name as before and reads no statement at all. - A replacement published after the opening ACK, or between the opening response and its ACK, waits for the ACK of the response that carries it. The same holds on an agent that did not restart. - What a proxy stated never overwrites what any proxy acknowledged or rejected after the opening response was sent (a per-tracker sequence), nor a rejection of the very version it states. A hot-restart parent's late opening ACK no longer undoes a removal the child acknowledged. - A first request that unsubscribes from anything is not read: go-control-plane forgets the stated version of a name it unsubscribes from. The review's tests are kept (stated_review_test.go). The removal wait is unchanged: it is keyed by name and reads a listener it knows nothing of as absent. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…it rejected (#1511) Review: presence had become version-aware and the NACK check had not. A rejected listener followed by a same-named replacement failed the replacement's wait at once with the predecessor's error, and a rejected removal failed a wait for the listener to be present. With a PublishedVersion, a NACK fails WaitListenerPresent only when the rejected version is the one published when the wait looks. The removal wait, and a tracker with no PublishedVersion, are failed by any rejection as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…swered response makes the acknowledged version unknown (#1511) Second review of the version-keyed listener wait. The tracker keeps one state per name, and two proxy generations write it during a hot restart. - An acknowledgement (added, removed, or what the proxy stated) is recorded only when nothing was written to the name after the response it answers was sent. A draining generation's late ACK of an older version erased the newer version the generation taking over had acknowledged, and nothing corrected it: every later wait for the name ran to its deadline, where main returned at once. The same rule keeps an older add from undoing an acknowledged removal (which main did too) and an older removal from undoing a newer add. A rejection is still always recorded. - The state is what a proxy acknowledged, not what it was last sent. A wait is not answered while the stream that wrote the state has an unanswered response adding or removing the listener, even at the published version (the agent went back to it). A stream that closes with such a response unanswered leaves the listener present at no known version. The review's tests are kept (stated_review2_test.go, cache/ackpublished_race_test.go). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…stener ACK state (#1511) Review: one rejection is kept per name, and during a hot restart the draining generation's NACK of an older version replaced the new generation's NACK of the published one. The wait then ran to its deadline instead of failing with the proxy's error. A rejection is still recorded whatever was acknowledged since its response was sent; it is only not recorded over a rejection newer than that response. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…ange-resolves-listener-waits # Conflicts: # agent/internal/cmd/root.go # agent/internal/xds/ack/opening_test.go # agent/internal/xds/ack/tracker.go # agent/internal/xds/cache/BUILD.bazel
…e the tracker's lock; comments after the merge of #1528 (#1511) The merge commit before this one resolves the ACK tracker to one opening-statement bookkeeping (streamTypeState): the statement goes to the AckObserver as #1528 has it, and resolves a listener wait only when the first response is the name-by-name comparison of it (compared) and a published version is wired. A stream close now also wakes waiters before it tells the DeliveryObserver; the new test holds that the observer still runs with the lock released. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
… their responses were sent, and a wait reads state and published version together (#1511) Review of the merged ACK tracker. - The order between two answers was taken from a counter that advanced only when a response was answered, so two responses sent to two proxy generations before either answered carried the same value. The one sent the newer version, answering second, was discarded: presence stayed on the older version, or the rejection of the published version was dropped. Every kept response now takes a tick of a clock when it is sent. An acknowledgement is recorded when its response was sent after the one on record; of two rejections the one of the response sent last is kept; an acknowledgement clears a rejection when its response was sent after the rejection arrived. - The wait reads the state under the tracker's lock and the published version outside it. If the state changed in between, the pair was never true together: the wait looks again instead of answering from it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…ange-resolves-listener-waits
…held for the removal wait (#1511) Review: a stream that closed with the add of a listener unanswered left the listener absent when that stream had acknowledged its removal before, or when nothing was known of it. The proxy may have applied the add before the answer was lost, and a pod DEL then skipped its removal wait. Such a listener is now present at no version and marked unconfirmed: the removal wait waits for its acknowledgement and no presence wait is answered by it, with or without a published version. Another generation's acknowledged removal stands, and an unanswered removal makes nothing present. Also states, where the tracker's clock is declared, what it orders: when responses were written to their streams, which is the order the cache computed them in unless a stream's goroutine is held up in between. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…what a closing stream leaves uncertain is ordered like an answer (#1511) Review of the two rules added last. - A wait rechecks its state only when the tracker's broadcast channel closed, and filing a response in flight did not close it. A response sent between the wait's two reads was missed. It now wakes the waits. - A closing stream's unanswered response was kept from overriding state by comparing which stream wrote it. It is ordered like an answer now, by when the response was sent, and the uncertainty takes that place in the order: another generation's later answer stands, an earlier one does not hide the add that may have been applied, and an older ACK arriving late does not settle it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Comment on lines
+390
to
+391
| failed := st.nackFails(wantPresent, published, typeURL, name) | ||
| answered := st.answers(wantPresent, unanswered, published, typeURL, name) |
bpalermo
marked this pull request as draft
October 9, 2026 23:27
This was referenced Oct 9, 2026
Closed
Owner
Author
|
Superseded by #1624 (a per-stream ACK tracker), closed on the owner's decision. The branch is kept so #1624 can take its tests. 🤖 Generated with Claude Code |
bpalermo
deleted the
fix/1511-opening-exchange-resolves-listener-waits
branch
October 11, 2026 05:16
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 #1511
The problem
After an agent restart the proxy already holds every pod listener. It states them in the
initial_resource_versionsof its first Listener request, go-control-plane finds them at the version it publishes and sends nothing for them, so nothing ever acknowledges them by name. For such a listener:Tracker.WaitListenerPresentran to the caller's deadline (the CNI server's 2 s ACK wait on a pod ADD that is retried, or a pod re-added, after the restart);Tracker.WaitListenerAbsentreturned at once, because the new agent knew of no listener to wait for.The change
Two things, the second forced by review of the first.
WaitListenerPresentis answered only when that is the version the agent publishes at the moment the wait looks. The node agent wires this withSetPublishedVersion(ack.SnapshotVersions(snapshotCache, node)), which reads the same per-resource version map go-control-plane computes its responses from.Why the second: a pod's listeners are named after the pod (
outbound_http_<pod>,inbound_<pod>). A same-named replacement publishes other content under a name the proxy already holds, so "the proxy stated this name" says nothing about the replacement. The same was already true onmainof "the proxy once acknowledged this name" on an agent that did not restart; this change closes that too.A rejection is read the same way: a NACK fails
WaitListenerPresentonly when the rejected version is the one published when the wait looks, so a predecessor's rejection or a rejected removal does not fail a replacement's wait (second Copilot round; four mutations of that rule killed). The removal wait is failed by any rejection, as before.A tracker nobody gave a published version to (the edge agent, tests) keys presence by name as on
mainand reads no statement at all.Functions touched in
agent/internal/xds/ack/tracker.go:resourceState,inflightResponse,Tracker(fields),NewTracker,wait,onDeltaResponse,onDeltaRequest,onDeltaStreamClosed; newPublishedVersion,SnapshotVersions,SetPublishedVersion,atPublishedVersion,rejectedLocked,acknowledgedLocked(the two halves ofonDeltaRequest, split for the complexity lint),noteRequestLocked,opensWildcard,statedHeld. One line inagent/internal/cmd/root.gowires it. No change to the CNI server or to the cache's production code.Merged over #1528
main(with #1528, the per-cluster acknowledged-pin gauge) is merged into this branch; the function list above is from before that merge. The tracker now has one opening-statement bookkeeping, #1528'sstreamTypeStateper (stream, type), with one field added:statedis kept for every first nonce-less request of a type and handed to theAckObserverinAccepted.Stated, exactly as fix(agent): the acknowledged SAN-pin gauge is kept per cluster and never counts a cluster the proxy rejected (#1508) #1528 has it. Nothing in fix(agent): the acknowledged SAN-pin gauge is kept per cluster and never counts a cluster the proxy rejected (#1508) #1528's observer contract changed:AcceptedandDeliveryare built from the same fields, and both observers are still called aftert.muis released.compared(new) says the first response is certain to be the name-by-name comparison of that statement with the snapshot: plain wildcard, nothing unsubscribed, no second request of the type before the first response. Only then, and only with a published version wired, doeskeepLockedcomputeheldfor the listener waits.Functions that changed in the merge, against
main:resourceStatenackVersion,nackSentAt,nackAt,version,sentAt,stream,unconfirmedstreamTypeStatecomparedinflightResponseheld,sentAt(versions come from #1528'sadded []Resource)Trackerclock,publishedkeepLockedheldon the opening response; ticksclockand stampssentAtnoteOpeningRequestLocked→noteRequestLockedcompared, clears it on a second request before the first response; what it keeps asstatedis unchangedonDeltaRequestnoteRequestLockedfirst; passes the stream toresolveLockedresolveLockedrejectedLocked/acknowledgedLocked;nackLockedis gone (folded intorejectedLocked)onDeltaStreamClosedDeliveryObserver(still outside the lock)waitPublishedVersion,SnapshotVersions,SetPublishedVersion,unansweredLocked,nackFails,answers,isClosed,atPublishedVersion,opensWildcard,statedHeld,rejectedLocked,acknowledgedLocked,unansweredForgottenLockedInvariants the merged tracker keeps:
initial_resource_versionsof the first nonce-less request of a (stream, type); it moves to the first response of the pair and is released with it, or with the stream.held= stated − added − removed of that response, with the stated versions; computed only ifcomparedand a published version is wired; applied only on that response's ACK.clockwhen it is sent (sentAt), so no two share one. Nothing else ticks the clock.sentAtorder, whatever order the answers arrive in). A recorded ACK clears a rejection only if its response was sent after the rejection arrived (nackAt).heldnever clears a rejection of the version it states.nackSentAt). It keepspresentandversion.present, no unanswered response adding or removing the name on the writing stream, andversionis the published one (no published version wired: any version).t.muor from a stream callback; observers are called only witht.mureleased.unconfirmed: the removal wait waits, no presence wait is answered. Like the blanked version of invariant 9, it is ordered as an answer would be: it does not replace what the answer to a response sent later says, and it takes the unanswered response'ssentAt(fifth and sixth Copilot rounds).Known limit, not fixed (fifth Copilot round; answered in its thread): the clock ticks in go-control-plane's response callback, on the stream's goroutine, after the cache computed the response. It orders two streams' responses by when they were written. If the older stream's goroutine is held up between taking its response and running the callback for longer than the other stream takes to be written to, answered and written to again, the order inverts and the older answer is recorded over the newer: a wait then runs to its deadline until the listener is next sent (never one answered early). Ordering by the snapshot needs the cache to give the tracker an order. The cleaner fix is state per stream instead of one per name, which removes every cross-generation rule above; that is a change of the tracker's model and its own review.
One assumption stated in the code: a request that carries a nonce before anything was seen of its type on the stream is not kept (as on
main, and as #1528's tests require for a request that arrives after its stream closed). A proxy that follows the protocol cannot send one.Mutation spot-check of the merged file (all killed): a statement resolving waits with no published version; the sequence rule dropped; the
AckObservercalled under the lock (the suite deadlocks); theDeliveryObservercalled under the lock on close (new test); a second request leaving the statement comparable; every statement comparable;sentSeqnot recorded; the unanswered response not forgotten on close; the statement not released at the first response; an older rejection replacing a newer one; the statement no longer handed to the observer (#1528's tests).What is guaranteed, and what is inferred
Measured:
resource_names_subscribeempty, nothing unsubscribed) and states every listener it holds at the version it was sent.//agent/test/mtlspool,TestReconnectingProxyStatesTheListenersItHolds.stated_server_test.go.TestReconnectingProxyStatesNoListenerVersionItWasNotSent.TestAckTrackerReadsThePublishedListenerVersionFromTheCache) and against the pinned proxy (a replacement published under a held name is answered only by the ACK of the response that carries it).Inferred from that: the proxy holds the listener at the stated version and accepted it. That is what the ACK of a response carrying the listener says, and no more.
What is not concluded:
The state is per name, for the node
As on
main, the tracker keeps one state per resource name, not one per stream: during a hot restart two proxy generations write it. Three rules order their answers (second review):mainit did (the removal case), and the first version-keyed revision made the version case a regression: the wait then ran to its deadline for ever.One rejection is kept per name; an older one does not replace a newer one (third Copilot round), and when rejections of two versions arrive in publication order only the later is on record.
Known limits of one state per name, stated in the code and the runbook: an answer may be one generation's (either's ACK resolves, either's NACK fails); and if a draining generation rejects a version the new one accepted and then exits, the wait for that version fails with the stale rejection until the listener is sent again.
The cases the review found
All four failed on the first version of this change; the tests are kept in
stated_review_test.go.subscribe ["*"],unsubscribe [L], statingLBehaviour changes to know about
aether_agent_xds_ack_wait_failures_total:{wait="present",reason="timeout"}stops counting listeners that were there all along and starts counting replacements the proxy did not acknowledge in time;{wait="absent",reason="timeout"}can count removals that went uncounted.docs/runbook.mdsays so.Tests
Seen red: the six positive tests of the first version against the unchanged tracker;
TestReconnectingProxyStatesTheListenersItHoldson the pinned proxy (30 s at the wait); the four review tests on the first version of this change.Mutations of
tracker.go, each against//agent/internal/xds/ack:ack_test:*disqualifies the first requestSnapshotVersionsreports an unversioned resource as publishedstatedHeldignoresadded, or ignoresremovedRun:
bazel test --config=raceon//agent/internal/xds/ack,//agent/internal/xds/cache,//agent/internal/xds/server,//agent/internal/cni/server,//agent/internal/cmd,//agent/test/mtlspool;ack_testand the pinned-proxy listener tests 50 times each; lint on the touched packages;make format-check.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr