Skip to content

fix(agent): the acknowledged SAN-pin gauge is kept per cluster and never counts a cluster the proxy rejected (#1508) - #1528

Merged
bpalermo merged 24 commits into
mainfrom
fix/1508-acked-pin-per-cluster
Oct 9, 2026
Merged

bpalermo merged 24 commits into
mainfrom
fix/1508-acked-pin-per-cluster

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Closes #1508

Reproduced

The issue was inferred. It reproduces, end to end, on the pinned proxy with the pinned go-control-plane server and the agent's ACK tracker (//agent/test/mtlspool, TestAckAfterARejectedClusterUpdateIsNotAnAckOfTheSnapshot, first written against the tracker on main and seen failing):

step on the wire what the proxy holds (admin config_dump) what the tracker told the gauge
snapshot v1: clusters a, b response carries a, b; ACK a@8626ff…, b@91a2ba… v1 acknowledged
v2: a becomes a cluster the proxy refuses response carries a; NACK (Error adding/updating cluster(s) a) unchanged nothing
v3: b changes, a still the refused one response carries b alone; ACK a@8626ff… (the v1 one, connect_timeout: 11s), b@a6b9d8… v3 acknowledged

After the last step the proxy's own statement on a new stream (initial_resource_versions) is a@8626ff…, b@a6b9d8…, while snapshot v3 has a@7eeb30…. The gauge took v3's counts, a included.

The same at the gauge, against the real SnapshotCache and the pinned go-control-plane watch logic (//agent/internal/xds/cache, TestAckedPinGaugeAfterARejectedClusterUpdate, also seen failing on main): an unpinned cluster is pinned, the proxy rejects it, another cluster is added and acknowledged. main reported unpinned{no_namespace_metadata}=0, pinned=3; the proxy held the unpinned cluster.

The change

The acknowledged state is kept per cluster, from the two things a proxy says.

  • An ACK is about the clusters its response carried. The tracker now tells its observer the resources an acknowledged response added, with the per-resource version each was sent at, and the ones it removed (ack.Accepted), not a snapshot version to look counts up by.
  • The first request of a type on a stream states every resource the proxy holds, by version. The tracker keeps that statement and hands it over with the answer to the first response of the stream. Acknowledged, the proxy holds what it stated with the response over it. Rejected, it holds what it stated and nothing of the response. This is fix(agent): the acknowledged SAN-pin gauge has its sample after an agent restart against a proxy that is in sync (#1483) #1504's first-response rule made exact: the empty opening response is still kept, a later empty response is still dropped (it carries no cluster), and a later request without a nonce (an on-demand subscription) is not read as a statement.

The cache keeps one record per cluster entry: the version the proxy accepted, every version in flight (sent in a response the proxy has not answered yet) with the pin class that version was last published with (review round 6), and the last three versions published. The gauge is the count over those records.

An ACK is read against the in-flight versions, so it is known however long the proxy takes and however many times the cluster is rebuilt meanwhile. The tracker tells the cache when a response enters flight and when it leaves (ACK, NACK or the end of its stream; ack.Delivery). The three published versions are only what that copy is made from at send time, and what an opening statement is read with.

  • A rejected cluster stays at the version the proxy last accepted through every later ACK, until a response that carries it is acknowledged. One it never accepted is in no series.
  • Removals: a cluster that left the snapshot stays counted until the proxy acknowledges its removal or opens a stream without it. A rejected removal keeps it.
  • Memory: one record per cluster entry of the newest snapshot, plus one per entry the proxy still holds, or has not answered for, after it left, plus one per entry that left in the last two builds (review round 4). A record is a fixed size plus one small item per version of that cluster in flight, which is at most one per unanswered response carrying it; the tracker drops a stream's unanswered responses when the stream ends. So it is bounded by clusters times connected proxy streams (one, two during a hot restart), with nothing per snapshot or per ACK; the 64-slot snapshot ring is gone. A snapshot build still allocates nothing per cluster at rest (TestPinReportCostsNoAllocationPerCluster).
  • A cluster entry's record is keyed by the name of the cluster it publishes. That is not always its map key: a service's default entry is keyed by the bare service name and publishes a cluster named by the FQDN.

What changes for a reader of the gauge

What it cannot know

  • The pin state of a version this agent process never published (above). observability: the proxy-holds-unpinned alert goes silent when the agent restarts while the proxy is rejecting cluster updates #1509 stays open.
  • A cluster the proxy holds that is not a cluster entry of a snapshot this process built is in no count.
  • Accepted is not applied. Envoy applies the valid clusters of a response it then rejects as a whole and keeps stating the old versions (TestRejectedResponseAppliesItsValidClusters measures it: the admin dump shows the new version, the statement the old). A proxy that rejects its first cluster response has accepted nothing and counts nothing, although it runs the valid clusters. They come back one by one as they change, because a rejected response is not sent again (agent: a cluster update the proxy rejected is never sent again on that stream #1510, not solved here).
  • Two proxy generations during a hot restart share one record per cluster: each cluster shows the last answer from either, and a generation's opening answer replaces the set. The residue is now per cluster instead of per snapshot (TestAckedPinGaugeWithTwoProxyGenerations writes it down). Not exercised with a real hot restart.

Red, then green

Seen failing on main before the fix:

  • //agent/test/mtlspool TestAckAfterARejectedClusterUpdateIsNotAnAckOfTheSnapshot ([]string{"v1", "v3"} should not contain "v3").
  • //agent/internal/xds/cache TestAckedPinGaugeAfterARejectedClusterUpdate (expected no_namespace_metadata: 1, got 0; expected 2 pinned, got 3).

The other tests were added with the change, so each was checked by mutation; twelve mutations here and five more in review round 1 (below), every one caught, all reverted:

mutation caught by
an ACK is read as the whole newest snapshot (the old behaviour) 8 cache tests
a later NACK is told as an ACK the Envoy test, 2 more Envoy tests, 6 cache, 4 tracker tests
a rejected opening exchange is not read …MakesNoClaimForAProxyThatIsNotInSync, …WhenTheAgentRestartsWhileTheProxyRejects
a held cluster of unknown state is left out and the rest reported …WhenTheAgentRestartsWhileTheProxyRejects, TestAckedPinsAreBoundedByTheClusters
an acknowledged removal is ignored …AfterARejectedClusterUpdate, …KeepsAClusterWhoseRemovalWasRejected
any request without a nonce is a statement TestAckObserver_NotToldOfALaterEmptyResponse, 2 cache tests
an opening exchange does not replace the set TestAckedPinsAreBoundedByTheClusters
a build never re-counts what the proxy holds …FollowsAReclassificationOfWhatTheProxyHolds
an ACK is read at the newest version, not the one sent 3 cache tests
the classes are recorded after SetSnapshot TestSnapshotPinClassesAreRecordedBeforeItCanBeAcked
an entry is recorded under its map key, not its cluster's name TestAckedPinGaugeIsWhatTheProxyAcknowledged, TestTLSNotPublishedIsNeverTheReasonOfASnapshotThatCarriesTLS
the statement is dropped 3 cache, 4 tracker tests

With the change: //agent/... and //:observability_rules_test pass; --config=race passes on ack_test, cache_test and mtlspool_test, plus 12 runs of the five Envoy CDS tests; lint (--config=lint with fail_on_violation) and make format-check are clean.

Contract

The external-harness contract changes: version 1 → 2 (test/harnesscontract/external-harness.yaml, entry agent.xds_acked_tls_clusters).

aether_agent_xds_acked_tls_clusters keeps its name, type and labels (pin, and reason on the unpinned series, the same closed set). What it counts changes:

  • Version 1: the counts of the last snapshot whose cluster update the proxy acknowledged; absent until the first cluster ACK.
  • Version 2: the count of the clusters the proxy has accepted, each at the version it last acknowledged or stated when it opened its stream.

What a harness written against version 1 must change:

  • Do not read a cluster ACK as "the proxy holds the newest snapshot". A rejected cluster stays at the version the proxy last accepted through later ACKs of other clusters, so this gauge can stay above aether_agent_snapshot_tls_clusters for as long as the proxy rejects.
  • Treat an absent series as "not known", never as zero, and expect the series to become absent after having had samples: while the proxy holds a mesh cluster whose pin state the agent cannot determine, all series stop, and they return when it can. A grader that carries the last sample forward is wrong there.
  • The first sample can come from the answer (ACK or NACK) to the first cluster response of a stream, not only from an ACK that changed a cluster.

The README beside the contract has this as a "Versions" table, and its rule table now names this kind of change. Review round 8 (one thread on d125d98b, answered in f38d59de) is this section; nothing else changed in it, and the metric's behaviour is as the rounds above left it.

Review round 1

  • A version in flight was forgettable (the reviewer was right). Reproduced first: TestAckedPinGaugeKnowsAVersionHoweverLongItsAckTakes rebuilds a cluster nine times while its response waits, then acknowledges it; before the fix the gauge stayed on its old value and the agent logged the version as one it never published. Fixed as described above. What remains bounded by a count is the step between go-control-plane building a response and the stream's goroutine handing it to the tracker, inside the agent process: a cluster rebuilt three times in that step is sent with no class on record. I did not find a hook that closes it.
  • Five more mutations, all caught and reverted: a sent version not recorded; never released; a closed stream leaving its responses in flight; a response leaving flight before its ACK is read; a record dropped while its cluster is in flight (this one survived at first, and TestAckedPinGaugeCountsAClusterRemovedWhileItsResponseWasInFlight was added for it).
  • The gauge's registered description and field comment, the runbook's "never above", and the runbook query (now clamped per series, with its mirror) are corrected.

Review round 2

  • A gauge that had been written stayed on its last values while unknown (raised in the review summary, no thread). True: it was a recorded gauge, which exports its last values for the life of the process. Reproduced first (TestAckedPinGaugeIsWithdrawnWhenAHeldClusterBecomesUnknown, red), then the instrument was made an observable gauge that has no sample while the state is unknown, and has one again when it is known. One more mutation (the withdrawal removed), caught and reverted. Same name, type and series for a reader; an OTLP backend sees the series stop instead of repeating.

Review round 3

Three points from the review summary of b3ca2c2d, none as a thread:

  • A late ACK was read with the class the version was sent with, even when a later snapshot counts the same bytes under another reason. True. Reproduced first (TestAckedPinsReadALateAckWithTheClassOfNow, red: tls_not_published where the newest snapshot says no_namespace_metadata). An ACK is now read with the class a remembered snapshot gives the version, and with the sent copy only for a version no snapshot remembers.
  • "Absent while no proxy is connected" was too wide. The gauge is absent until a proxy has answered the agent process at all; once it has samples a dropped stream does not withdraw them. The rule comment, the README and the runbook now say so ("a sample is not a live connection").
  • The alert summary still said "last acknowledged". It now says the proxy "holds" the clusters; the four promtool expectations follow.

Review round 4

Five threads on 37d8b0e7, answered in 72da067a and 85046b9a:

  • A record could be dropped before the response that carries its cluster was written. True. go-control-plane builds a response from the snapshot of the moment and the tracker learns of it only when the stream writes it; a build that removed the cluster in between dropped the only copy of the version's class, and the ACK that followed was ignored: the gauge left out a cluster the proxy held. Reproduced first (TestAckedPinGaugeCountsAClusterRemovedBeforeItsResponseWasWritten, red: 0 where the proxy had accepted one unpinned cluster). The record of an entry that left the snapshot is now kept for three builds (goneBuilds) before it is dropped when nothing holds it, the same in-process step and the same count offeredVersions covers for a rebuilt cluster. A response that waits longer than two builds to be written is still not counted; there is no hook for "a response was built". Three assertions that a record is gone with the answer now build past that window first. Two mutations (window one build shorter, one longer), caught and reverted.
  • A plaintext UDP floor entry was tracked. True. Its class is never applicable, but a proxy stating it at a version this process never published, and rejecting the update, withdrew the whole gauge. Reproduced first (TestAckedPinGaugeIsNotWithdrawnForAPlaintextUDPFloor, red). It is no longer tracked: no record, in no count.
  • "Validate the snapshot before recording, in case SetSnapshot rejects it." Not changed: the pinned go-control-plane (v0.14.0) does not validate in SetSnapshot; it stores the snapshot first and can fail only while answering open watches afterwards, so a snapshot whose set returned an error is still the one served and a proxy can acknowledge it. TestAckedPinsKnowASnapshotWhoseSetReturnedAnError holds that and fails if the record is made conditional on success (mutation run, reverted).
  • The divergence alert's description said "1 more mesh clusters"; it says "cluster(s)". A test named after the removed pin history is renamed.

Review round 5

Four threads on ea48a86b, answered in 1bb6d60f. tracker.go is not touched.

  • A report could overtake a later one. True. The state changed under its mutex and the gauge and log were written after it was released; with two proxy generations on two stream goroutines, or a build and an answer, the gauge could end on the older state, or be written after a later change withdrew it. Reproduced deterministically (the first report is stopped in the log handler, before the gauge write, and the second change runs meanwhile): TestAckedPinGaugeIsWrittenInTheOrderTheStateChanged (two cases) and TestAckedPinGaugeIsWrittenInOrderAcrossABuildAndAnAnswer, red. The change and its report are now one critical section. Not a revision that discards stale reports: the discarded one can be the one that carried the log line.
  • A stated cluster with no record was left out of a count reported as complete. (The family list named here was widened and moved in round 6.) True, two ways: the record dropped before the proxy reconnected (TestAckedPinGaugeIsNotCompleteWithAStatedClusterItHasNoRecordOf, red) and dropped while the opening response waited for its answer (TestAckedPinGaugeWhenARecordIsDroppedWhileTheOpeningAnswerIsAwaited, red). A stated name with no record is now held at a version of unknown class, which withdraws the gauge, unless the newest snapshot publishes it (then it is not a cluster entry) or its name is of a family that carries no pin of its own (per-pod, QUIC twin, UDP floor). It ends when the proxy accepts the removal, stops stating it, or the agent publishes that version again. The rule errs to "unknown". Removals are not added to the in-flight lifetime: that covers only the second way.
  • Every cluster ACK recounts every record. Measured, left: BenchmarkAckedPinsAccept gives about 2 µs, 26 µs and 400 µs per ACK at 200, 2,000 and 20,000 cluster entries, no allocation.
  • Five mutations, all caught and reverted: the published-name check removed; the family check removed; the published names not kept; the report moved back outside the lock in ClustersAccepted; the same in publishAckedPins.
  • Not changed, and bounded by the above: the ACK of a cluster with no record (a response written more than two builds after its entry left) is still not counted until the proxy's next opening statement names it.

Review round 6

Eight threads on bfdec418, answered in e679bf64. tracker.go is not touched. Closes #1586.

  • A late ACK was read with the class its version was first sent with. True, and with one response, not only with two streams: a version sent as tls_not_published, counted as no_namespace_metadata by a later build, and acknowledged after it fell out of the published versions was read with the old reason (TestAckedPinsReadALateAckWithTheLastClassItsVersionWasPublishedWith, both cases red). The copy kept while a version is in flight now follows every reclassification of that version. The class belongs to the version's bytes as last published, so one class per version is right for every response and stream that carried it; no correlation of an answer with its delivery is needed, and nothing is reported as unknown for this case.
  • The no-pin families were incomplete (agent: the acknowledged-pin gauge is withdrawn while a proxy keeps a non-pin cluster outside the tracker's deny-list #1586). True: a stale statement for the passthrough, the blackhole, a waypoint ingress cluster or an edge cleartext backend cluster, with the opening removal rejected, withdrew the gauge (TestAckedPinGaugeIsNotWithdrawnForAStaleClusterItDoesNotCount, red). The list is now proxy.ClusterNameOutsidePinGauge, beside proxy.IsMeshEntryClusterName, built from the constants the name builders use. TestEveryClusterConstructorIsOfAClassifiedFamily scans the proxy package for every function that builds a cluster and fails until a new one is listed and its names are classified by exactly one predicate; TestEveryPublishedClusterIsACountedEntryOrOutsideThePinGauges holds the same for what a node agent (both capture modes) and an edge publish, over eleven families.
  • "An entry with no cluster in the snapshot is never in the acknowledged gauge" was too wide (six threads, one point). A floor that was published and whose removal the proxy rejects stays counted at the version it accepted. The behaviour was right (TestAckedPinGaugeKeepsAFloorWhoseRemovalWasRejected, new, passed on the previous head); every copy of the statement is qualified: code comments, a test name and comment, the README, the runbook, the rule comment and the rule-test fixture.
  • Four more statements that were wider than the code, found by re-reading the diff: "the ACK of a version this agent sent always finds its class" (not when the version had fallen out before its response was written); "every entry has its record" (not the plaintext UDP floor); "it takes its own mutex and nothing else" (also the gauge's mutex and the log handler under it, since round 5); the runbook's "a slow proxy loses nothing" (now states the two in-process bounds).
  • Four mutations, all caught and reverted: the in-flight class not updated; the passthrough, the waypoint prefix, the edge prefix each removed from the list.

Review round 7

Four threads on 20fdea2a, prose and naming, answered in d125d98b. No behaviour change except the text of two log lines. tracker.go is not touched.

  • proxy.ClusterNameCarriesNoPin is now proxy.ClusterNameOutsidePinGauge (the names above are updated). The old name was untrue of the per-pod inbound-readiness cluster, which is mTLS pinned to its pod's SPIFFE ID, and of a QUIC twin. The predicate says where a cluster is counted, not what TLS it has.
  • The WARN for the unknown state no longer says "at a version this agent did not publish" (this process may have published it and dropped the record). It is proxy holds mesh clusters whose pin state this agent cannot determine; the acknowledged pin gauge is not written; the INFO that ends it speaks of the clusters the agent has on record.
  • Comments corrected against the code: an update is reported under the lock; when a held version is unknown (three ways, none of them "fell out while in flight"); "not held" is what the agent has read, not what the proxy has; a build moves the acknowledged gauge in two cases, not one; the transitions to and from unknown are logged too.
  • Docs: the runbook said a stated cluster the agent has no record of "is in no series"; since round 5 it is the unknown state. The README and the rule comments said "holds" where the gauge knows "has accepted". Timing claims ("within a second") are now "normally". The second cause of an absent gauge is named beside the first.

Tests of #1504 whose expectation changed

  • TestAckedPinGaugeMakesNoClaimForAProxyThatIsNotInSync: after the rejected opening exchange the gauge now has a sample, the unpinned cluster the proxy stated. It asserted absence.
  • TestReconnectingProxyStatesNoClusterItRejected: the tracker now tells the statement for the rejected opening exchange; the test asserts the reading equals the versions the proxy accepted. It asserted that nothing was told.
  • TestAckObserver_EmptyOpeningResponseThatIsNotAcknowledged is replaced by …OpeningResponseCarriesTheStatementWhateverItsAnswer and …OpeningResponseThatIsNotAnswered.
  • TestPinHistoryIsBounded is replaced by TestAckedPinsAreBoundedByTheClusters; the ring it tested is gone.

Docs and rules

  • docs/runbook.md, "The unpinned-cluster signal", "Published is not held": rewritten for the per-cluster state, with a query for clusters the proxy has not accepted.
  • docs/observability/agent-pin-alerts.yml: comments, and the summary and description annotations of AetherProxyHoldsUnpinnedClusters (they said "last acknowledged"). No expression changed.
  • agent-pin-alerts_test.yml: two cases added (a rejected pin stays held through later ACKs of other clusters; an entry no proxy can hold is quiet).

Not verified

  • Nothing was run on a cluster. The evidence is the unit tests and the real-proxy harness.
  • A real hot restart with two generations connected was not run; the two-generation behaviour is tested against the cache with two simulated streams.
  • The stated versions of a proxy with on-demand (quic:) clusters were not measured; those clusters are not cluster entries and are in no pin count.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…ver counts a cluster the proxy rejected (#1508)

aether.agent.xds.acked_tls_clusters took the pin counts of the snapshot
named by the last cluster ACK. An ACK covers the clusters its response
carried, and go-control-plane does not send a cluster again after the
proxy rejected it, so the ACK of any other cluster moved the gauge to a
snapshot that counts the rejected cluster in its new state.

The ACK tracker now tells its observer what an answer says the proxy
holds: the resources an acknowledged response carried, by version, and
for the first response of a type on a stream the proxy's own statement
(initial_resource_versions), whatever the answer. The cache keeps one
fixed-size record per cluster entry (the versions it published with their
pin class, and the version the proxy accepted) and counts the gauge from
those records.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

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

In-flight cluster records and versions can be discarded before their ACK arrives, causing the acknowledged gauge to omit accepted clusters.

4 open findings
What changed in this PR

Reworks acknowledged SAN-pin tracking from snapshot-level to per-cluster state so rejected clusters are not incorrectly counted after unrelated ACKs.

Changes:

  • Adds per-resource ACK/opening-stream observations.
  • Replaces snapshot history with per-cluster accepted-version tracking.
  • Expands proxy, cache, alert, and documentation coverage.
File Description
docs/​runbook.md Documents per-cluster gauge semantics.
docs/​observability/​README.md Updates observability guidance.
docs/​observability/​agent-pin-alerts.yml Revises alert explanation.
docs/​observability/​agent-pin-alerts_test.yml Adds alert scenarios.
agent/​test/​mtlspool/​cds_reconnect_test.go Validates reconnect state.
agent/​test/​mtlspool/​cds_partial_reject_test.go Tests partial rejection behavior.
agent/​test/​mtlspool/​BUILD.bazel Registers the new test.
agent/​internal/​xds/​cache/​tlsnotpublished_test.go Adapts acceptance testing.
agent/​internal/​xds/​cache/​snapshot.go Records per-cluster pin classes.
agent/​internal/​xds/​cache/​pinreport.go Tracks published cluster identities.
agent/​internal/​xds/​cache/​pinhistory.go Removes snapshot-level history.
agent/​internal/​xds/​cache/​pinhistory_test.go Removes obsolete tests.
agent/​internal/​xds/​cache/​cluster.go Collects reusable class records.
agent/​internal/​xds/​cache/​cachemetrics/​cachemetrics.go Updates accepted-state recording.
agent/​internal/​xds/​cache/​cache.go Stores per-cluster ACK state.
agent/​internal/​xds/​cache/​BUILD.bazel Updates cache targets.
agent/​internal/​xds/​cache/​ackedpins.go Implements per-cluster tracking.
agent/​internal/​xds/​cache/​ackedpins_test.go Adds comprehensive cache tests.
agent/​internal/​xds/​ack/​tracker.go Reports per-resource accepted state.
agent/​internal/​xds/​ack/​tracker_test.go Adapts tracker tests.
agent/​internal/​xds/​ack/​opening_test.go Tests opening-stream statements.
agent/​internal/​cmd/​root.go Wires node-agent observer.
agent/​internal/​cmd/​edge.go Wires edge observer.

🧠 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/ackedpins.go Resolved
Comment thread docs/runbook.md Resolved
Comment thread docs/runbook.md Resolved
bpalermo and others added 2 commits October 9, 2026 10:13
…s answered (#1508 review)

The acknowledged pin state read an ACK against the last three published
versions of a cluster, so a cluster rebuilt more often than that while
its response waited for the proxy was acknowledged at a version the
agent had forgotten. The tracker now tells when a response enters and
leaves flight, and the cache keeps each sent version, with its pin
class, until every response carrying it is answered or its stream ends.

Also: the gauge's description, and two runbook statements.

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 13:19

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.

🔵 Needs a closer look

An already-recorded acknowledged gauge remains stale when cluster state later becomes unknown.

0 open findings

4 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Synchronous gauge retains stale values when version becomes unknown

agent/​internal/​xds/​cache/​ackedpins.go:426

When unclassified becomes nonzero after this gauge has already been recorded, returning here does not make the gauge absent: the synchronous OTel gauge retains its last recorded values (the existing cachemetrics test relies on that behavior). A later opening statement with an unknown version can therefore leave a stale, apparently valid acknowledged state exported indefinitely, contrary to the “not written while unknown” contract and potentially keeping the divergence alert wrong. The metric needs an explicit validity mechanism, such as an observable gauge that emits no observations while unknown (with corresponding tests for known → unknown), rather than merely skipping Record.

🧠 Review effort: Balanced

bpalermo and others added 2 commits October 9, 2026 10:27
…its last values, while a held cluster's pin state is unknown (#1508 review)

It was a recorded gauge, which goes on exporting its last values for the
life of the process: skipping the write left a stale state that read as
current. It is now an observable gauge with no sample while unknown.

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 13:30

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.

🔵 Needs a closer look

Per-cluster state can still become inaccurate during reclassification and multi-generation hot-restart sequences.

0 open findings

Previously missed (4)

In code that hasn't changed since last review

Medium severity In-flight ACK retains stale resource classification

agent/​internal/​xds/​cache/​ackedpins.go:168

When a later build reclassifies the same resource version, an ACK that was already in flight still uses the older sent class because this loop runs before the offered lookup. That can undo publish's reclassification and leave the acknowledged gauge under the old reason even though the current snapshot counts the identical bytes under the new reason (the mid-build tls_not_published promotion is the concrete case). Prefer the current offered class when that version is still known, falling back to the in-flight copy only after it has aged out.

This issue also appears on line 400 of the same file.

Low severity Gauge persists after all proxy streams disconnect

docs/​observability/​agent-pin-alerts.yml:168

The gauge is not withdrawn merely because all proxy streams disconnect; the last accepted state remains exported across reconnects. Therefore “absent while no proxy is connected” is only true before this agent process has received its first answer. Clarify that scope so operators do not interpret an existing sample as proof of a live xDS connection.

Low severity Summary incorrectly describes clusters as last acknowledged

docs/​observability/​agent-pin-alerts.yml:217

The description now correctly uses per-cluster accepted state, but the summary immediately above still says the proxy “last acknowledged” all $value clusters. There is no longer one last acknowledged snapshot or response containing this count; it can be assembled from many per-cluster answers. Update the summary (and its promtool expectations) to say the proxy “holds” these unpinned clusters.

Low severity Document disconnect behavior for agents with prior proxy state

docs/​runbook.md:5860

This currently implies that any down proxy makes the gauge absent, but disconnecting a stream does not withdraw the metric: the tracker deliberately preserves acknowledged state across reconnects, and only an unknown held version calls TLSClusterPinsAckedUnknown. Scope this example to a fresh agent that has not yet received any proxy answer, and mention that an existing sample survives stream disconnects.

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 9, 2026 13:42

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

A rejected opening removal can discard and omit a cluster the proxy still holds, producing an incomplete acknowledged gauge.

1 open finding
Previously missed (3)

In code that hasn't changed since last review

Medium severity Preserve clusters referenced by unanswered opening statements

agent/​internal/​xds/​cache/​ackedpins.go:412

A stated cluster can be silently omitted here after its entry was previously published and then removed. publish deletes a gone record when it is not yet marked held, while the opening statement remains only inside the tracker until the first response is answered; if that opening response contains the removal and is NACKed, restateLocked iterates no record for the stated version and settleLocked exports a complete count that excludes a cluster the proxy still holds. Preserve records named by an unanswered opening statement (or otherwise classify this state as unknown) until that exchange settles.

Low severity Describe accepted state instead of active cluster configuration

docs/​observability/​README.md:151

This description says the proxy “holds” the clusters, but the new partial-rejection test proves accepted state can differ from the active clusters Envoy runs. In that case the alert may report an old unpinned accepted version even though Envoy applied the newer pinned cluster. Describe this as the proxy's accepted state to avoid presenting the approximation as active configuration.

Low severity Use number-neutral wording for singular and plural counts

docs/​observability/​agent-pin-alerts.yml:218

For a value of 1, this renders as “1 more mesh clusters.” Use number-neutral wording so the alert description is grammatical for both singular and plural values.

🧠 Review effort: Balanced

Comment thread docs/observability/agent-pin-alerts.yml Resolved
…epted, not what it holds

Envoy can run a newer valid cluster from a response it rejected while still
stating the version it accepted, so "holds" claimed more than the gauge knows.

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 13:57

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.

🔵 Needs a closer look

Concurrent reports can overwrite newer gauge state, and opening statements can lose retained cluster classification.

0 open findings

1 resolved since last review
Previously missed (2)

In code that hasn't changed since last review

Medium severity Deleting in-flight opening records can permanently undercount the gauge

agent/​internal/​xds/​cache/​ackedpins.go:355

This can discard classification history before an opening exchange reveals that the proxy still holds the cluster. For example, this process publishes a, sends an empty opening response to a proxy stating a, then removes a before that response is ACKed; because opening statements are not included in Delivery, this branch deletes a. The opening ACK then makes restateLocked silently ignore stated a, so the gauge omits a held cluster, and a subsequent NACK of its removal leaves that undercount indefinitely. Preserve records named by an in-flight opening statement, or make missing stated entries unknown.

Medium severity Concurrent reports can overwrite the gauge out of order

agent/​internal/​xds/​cache/​ackedpins.go:535

accept releases ackedPins.mu before this reporting call, and snapshot builds do the same after publish. Those paths run concurrently, so an older update can be preempted after mutating h.counts, a newer update can report, and then the older call can overwrite the observable gauge (or withdraw/restore it) out of state order. Serialize each mutation together with its report, or attach a monotonically increasing update generation and discard stale reports.

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 9, 2026 14:02

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

Accepted-state mutation currently occurs before snapshot publication can fail, allowing an unpublished snapshot to alter the acknowledged gauge.

3 open findings

🧠 Review effort: Balanced

Comment thread agent/internal/xds/cache/snapshot.go Resolved
Comment thread docs/observability/agent-pin-alerts.yml Resolved
Copilot AI balanced review requested due to automatic review settings October 9, 2026 14:08

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.

Comment thread agent/internal/xds/cache/ackedpins.go Resolved
Comment thread agent/internal/xds/cache/ackedpins.go Resolved
Copilot AI balanced review requested due to automatic review settings October 9, 2026 19:55

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

The new exported classifier and operator diagnostics contain materially inaccurate SAN-pin semantics.

4 open findings

🧠 Review effort: Balanced

Comment thread agent/internal/xds/cache/ackedpins.go Resolved
… say no more than the code does; the family predicate is named for what it decides

Review round seven, prose and naming only. No behaviour changes except
the text of two log lines.

proxy.ClusterNameCarriesNoPin is proxy.ClusterNameOutsidePinGauge. The
old name was untrue as a statement about a cluster: the per-pod
inbound-readiness cluster is an mTLS cluster pinned to its pod's SPIFFE
ID, and a QUIC twin is pinned when its base is. The predicate says where
a cluster is counted, and its comment now says so.

The WARN for the unknown state said the proxy holds clusters "at a
version this agent did not publish". This process may have published and
sent that version and dropped the record since. It now says the agent
cannot determine their pin state, and the INFO that ends it speaks of
the clusters the agent has on record, not of every cluster the proxy
holds.

Comments corrected against the code: an update is reported under the
lock, not outside it; a held version is unknown when it was not on
record as its acceptance was read (three ways, none of them "fell out
while in flight"); "not held" is what the agent has read, not what the
proxy has; a build moves the acknowledged gauge in two cases, not one;
the gauge logs on the unknown transitions as well as on a change of
counts. The runbook no longer says a stated cluster the agent has no
record of is left out of the count (it is the unknown state), and the
README and the rule comments say "has accepted" where they said "holds".

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 20:11

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.

🔵 Needs a closer look

The concurrency-sensitive xDS state redesign is extensive, and real hot-restart behavior remains unverified.

0 open findings

4 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 9, 2026 20:42

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

The externally versioned metric contract still documents the old snapshot-level semantics and must be updated and version-bumped.

1 open finding

🧠 Review effort: Balanced

…ged pin gauge now counts, at version 2 (#1508)

This branch changes what aether.agent.xds.acked_tls_clusters means while
it keeps its name, type and labels: from the counts of the last snapshot
whose cluster update the proxy acknowledged to the count of the clusters
the proxy has accepted, each at the version it last acknowledged or
stated. A grader can observe the difference: the gauge stays above the
snapshot gauge while the proxy rejects a cluster, and its series stop,
after having had samples, while the proxy holds a cluster whose pin
state the agent cannot determine.

The contract entry (agent.xds_acked_tls_clusters) still described the
old meaning. It is rewritten, with both cases in which the series are
absent, and `version` goes from 1 to 2 as the contract's rule requires
for an entry that changes meaning. The README's table of what bumps the
version names this kind of change, and gains a "Versions" table saying
what a harness pinned to version 1 has to change. The runbook's contract
section points at it.

The metric's behaviour is not changed.

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 20:52

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.

🔵 Needs a closer look

The extensive xDS protocol and concurrency-state rewrite warrants final human review, particularly for real hot-restart behavior.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 9, 2026 21:03

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.

🔵 Needs a closer look

The cross-stream xDS state machine is concurrency-sensitive, and real hot-restart behavior remains unverified.

0 open findings

🧠 Review effort: Balanced

@bpalermo
bpalermo merged commit 77f9e8b into main Oct 9, 2026
31 checks passed
@bpalermo
bpalermo deleted the fix/1508-acked-pin-per-cluster branch October 9, 2026 21:19
bpalermo added a commit that referenced this pull request Oct 9, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants