Skip to content

fix(agent): the acknowledged SAN-pin gauge has its sample after an agent restart against a proxy that is in sync (#1483) - #1504

Merged
bpalermo merged 3 commits into
mainfrom
fix/1483-acked-pin-gauge-reconnect
Oct 9, 2026
Merged

bpalermo merged 3 commits into
mainfrom
fix/1483-acked-pin-gauge-reconnect

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Closes #1483

What was wrong

aether.agent.xds.acked_tls_clusters{pin,reason} is written when the proxy ACKs a cluster response. After an agent restart on a quiet node the gauge had no series until a cluster next changed.

The issue says the proxy "is owed no CDS response" in that state. That is not what happens on the wire, and it is where the fix is:

  • go-control-plane answers the first wildcard request of a stream even when it has nothing to add and nothing to remove (respondDelta: "otherwise, envoy won't complete initialization").
  • The proxy ACKs that empty response.
  • The agent's ACK tracker dropped every response that carried no resource, so the exchange was never matched to its ACK.

Can the agent truthfully conclude "the proxy holds snapshot X" from the reconnect?

Yes, from the first exchange of a stream, and only from that one.

  • The first Cluster request of a stream carries initial_resource_versions: the version of every cluster the proxy holds. Versions are the ones the control plane sent, which for go-control-plane are SHA-256 hashes of each cluster's bytes, so a new agent process with the same clusters computes the same ones.
  • go-control-plane seeds the stream's subscription with that map and compares it with the snapshot. For a wildcard subscription an empty first response therefore means the snapshot's clusters and the proxy's stated clusters are the same set at the same versions. Its system_version_info names that snapshot.
  • The tracker now keeps an empty response when it is the first of its type on its stream, and its ACK reaches the observer like any other. The pin history then gives that snapshot's counts to the gauge. When the stated versions differ, nothing changes: the difference is sent and the gauge moves on the ACK of that, as before. No claim is made without an ACK.

A later empty response is still dropped, and has to be. From its first response on, go-control-plane compares the snapshot with what it has sent on the stream, accepted or not, and it answers every wildcard request that has no nonce, which an on-demand cluster subscription is. After a rejected update that answer is empty, names the rejected snapshot, and is ACKed. Reading it as "held" would be false in exactly the state the gauge exists to show.

Measured and read

Measured on the pinned proxy, with the pinned go-control-plane server (//agent/test/mtlspool, two new tests):

  • A reconnecting proxy's first Cluster request states every cluster it holds at the version it was sent (subscribe=[], initial_resource_versions={held-a: d4843e…, held-b: 8e47d1…}), equal to the restarted control plane's own version map.
  • The server's answer is empty and carries the new snapshot's version; the proxy ACKs it.
  • After a NACK the proxy states none of the versions of the rejected response: the refused cluster is not stated, and the valid cluster of the same response is stated at its old version although the proxy applied the new one (read back from its admin config dump). The update is sent again after the restart and rejected again; nothing is read as acknowledged.

Measured on the pinned go-control-plane cache alone (//agent/internal/xds/cache): after a rejected cluster update the cache re-sends nothing, and a request without a nonce is answered with an empty response naming the rejected snapshot.

Read from source, not measured: that Envoy records a response's versions only after the response was accepted (DeltaSubscriptionState::handleGoodResponse at the pinned commit), which is what the NACK measurement above shows from outside; and that Envoy ACKs the later empty response (it has nothing to reject). The second was not reproduced with a real on-demand subscription.

Red, then green

Tests were written first and seen failing against the unchanged tracker:

  • //agent/test/mtlspool TestReconnectingProxyStatesTheClustersItHolds: the three protocol facts passed, the last assertion failed (expected: []string{"after-restart"}, actual: []string(nil)).
  • //agent/internal/xds/ack TestAckObserver_ToldOfAnAcknowledgedEmptyOpeningResponse and …OpeningResponseIsPerStreamAndPerType: failed.

The cache-level tests and the "not told" tests were added with the fix, so each was checked by mutation instead:

  • Dropping every empty response again (the old rule): fails 2 tests in ack, TestAckedPinGaugeAfterAnAgentRestartAgainstAnInSyncProxy in cache, and the Envoy test.
  • Keeping every empty response: fails TestAckObserver_NotToldOfALaterEmptyResponse, …PerStreamAndPerType and TestAckedPinGaugeMakesNoClaimForAProxyThatIsNotInSync.

Both mutations reverted. With the change: //agent/internal/xds/..., //agent/internal/cmd/... and the whole //agent/test/mtlspool:mtlspool_test pass; --config=race passes on ack_test, cache_test and 12 runs of the two new Envoy tests; lint (--config=lint with fail_on_violation) and make format-check are clean.

What this does not close

An agent that restarts while the proxy is rejecting a cluster update still has no acknowledged sample. The proxy states the clusters it held before the rejected update, which the new agent process never built and cannot count. It is sent the update again, rejects it again, and there is no acknowledgement to record. AetherProxyHoldsUnpinnedClusters is silent in that state (a divergence that was firing resolves when the old process's samples leave the lookback). I did not invent a value for it. It is now written down in the runbook ("The unpinned-cluster signal", "Published is not held"), in the rule's comment, and as a promtool case; the NACK counter still moves.

Docs and rules

  • docs/runbook.md: the restart behaviour, the two remaining absent states, and "acknowledged is accepted, not applied".
  • docs/observability/README.md, agent-pin-alerts.yml: comments only, no rule expression changed.
  • agent-pin-alerts_test.yml: two cases added (an agent restart with the proxy in sync is quiet; an agent restart while the proxy rejects silences the divergence rule). Run by hand with promtool 3.5.0: SUCCESS. The repository has no promtool target on this branch.

Not verified

  • Nothing was run on a cluster: the evidence is the unit tests and the real-proxy harness.
  • A proxy hot restart with two generations connected was not exercised here; the documented behaviour (the gauge shows the last ACK from either) is unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…ent restart against a proxy that is in sync (#1483)

aether.agent.xds.acked_tls_clusters is written when the proxy ACKs a cluster
response. After an agent restart on a quiet node it had no series until a
cluster next changed.

The issue says no cluster response is owed there. One is sent all the same:
go-control-plane answers the first wildcard request of a stream even with
nothing to add or remove, and the proxy ACKs it. The agent's ACK tracker
dropped every response that carried nothing, so that exchange was lost.

The first Cluster request of a stream carries, in initial_resource_versions,
the version of every cluster the proxy holds (a hash of the cluster's bytes).
go-control-plane seeds the subscription with them and compares them with the
snapshot, so an empty FIRST response says "the snapshot with this version is
exactly what you stated". The tracker now keeps that response and tells its
ACK to the observer like any other.

Only the first response of a type on a stream. A later empty response is
compared with what the server has sent on the stream, accepted or not, and
go-control-plane sends one for every wildcard request without a nonce (an
on-demand subscription). After a rejected update it names the rejected
snapshot and is ACKed; reading it as held would be false in the state the
gauge exists to show.

Measured on the pinned proxy (//agent/test/mtlspool): the reconnecting proxy
states every cluster it holds at the version it was sent, the empty answer is
ACKed, and after a NACK the proxy states none of the versions of the rejected
response.

Not closed, and documented: an agent that restarts while the proxy is
rejecting a cluster update has no acknowledged state to show (the proxy states
clusters the new process never built), so the gauge stays absent and the
divergence alert is silent there. A promtool case states it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 9, 2026 11:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Several updated documentation passages incorrectly imply that every Cluster ACK updates the gauge, despite later empty ACKs being deliberately ignored.

7 open findings
What changed in this PR

Fixes the acknowledged SAN-pin gauge after an agent restart by tracking the first empty CDS response per stream and resource type.

Changes:

  • Records ACKs for stream-opening empty responses while ignoring later empty responses.
  • Adds unit, cache, real-Envoy, and alert-rule coverage.
  • Updates operational documentation for restart and NACK behavior.
File Description
docs/​runbook.md Documents gauge behavior and limitations.
docs/​observability/​README.md Updates metric and alert guidance.
docs/​observability/​agent-pin-alerts.yml Expands alert-rule commentary.
docs/​observability/​agent-pin-alerts_test.yml Adds restart scenarios.
agent/​test/​mtlspool/​cds_reconnect_test.go Tests reconnect behavior with Envoy.
agent/​test/​mtlspool/​BUILD.bazel Registers the reconnect test.
agent/​internal/​xds/​cache/​pinhistory.go Documents acknowledged pin history.
agent/​internal/​xds/​cache/​pinhistory_test.go Tests gauge behavior across reconnects.
agent/​internal/​xds/​ack/​tracker.go Tracks opening responses per stream/type.
agent/​internal/​xds/​ack/​opening_test.go Tests opening and later empty responses.
agent/​internal/​xds/​ack/​BUILD.bazel Registers the tracker tests.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread agent/internal/xds/cache/pinhistory.go Resolved
Comment thread docs/observability/README.md Resolved
Comment thread docs/observability/README.md Resolved
Comment thread docs/observability/agent-pin-alerts.yml Resolved
Comment thread docs/runbook.md Resolved
Comment thread docs/runbook.md Resolved
… on (#1483)

The ACK of an empty cluster response later on a stream is not read. The
runbook, the catalog row, the rule comment and the cache comment said
'a cluster ACK' where they meant an ACK of a response that changed something
or of the empty response that opens a stream.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 9, 2026 11:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot AI balanced review requested due to automatic review settings October 9, 2026 11:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrowly scoped protocol change is comprehensively covered, including real-Envoy reconnect behavior and the unsafe post-NACK case.

0 open findings

🧠 Review effort: Balanced

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: the acknowledged SAN-pin gauge has no sample after an agent restart against an in-sync proxy

2 participants