Skip to content

feat(agent): the unpinned-cluster warning gives each cluster its own cause, and gauges record the SAN-pin state published and acknowledged (#1424, #1425) - #1479

Merged
bpalermo merged 2 commits into
mainfrom
feat/1424-1425-unpinned-cluster-cause-and-gauge
Oct 9, 2026
Merged

bpalermo merged 2 commits into
mainfrom
feat/1424-1425-unpinned-cluster-cause-and-gauge

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Closes #1424
Closes #1425

Builds on #1421 (the report leaves out the plaintext UDP floor).

What

#1424: each cluster gets its own cause. The WARN mesh clusters published with no server-identity SAN pin chose one reason for the whole line from the trust domain at the time of the report, so whenever the trust domain was known every cluster it named was said to have endpoints without namespace metadata. The cause is now recorded by the one function that can leave a pin empty (renderSANPin), on the cluster entry, and the report names each cluster under its own:

  • one line per reason per snapshot, and reason is a closed set of three: trust_domain_unknown (transient: ends with the first snapshot after the agent learns its trust domain), no_namespace_metadata (not transient: the registry serves endpoints with no namespace, so no SPIFFE ID can be built; this is the mTLS validation gap), pin_not_rendered (no code path does it; an entry that reached a snapshot unrendered gets a cause of its own instead of borrowing one);
  • at most 20 names per line, then .... So a snapshot logs at most 3 lines of 20 names however many clusters are unpinned. count is the reason's exact number; unpinned and pinned are the snapshot's totals.

The UDP floor is still named nowhere: it is plaintext by design, not unpinned (#1393).

#1425: what was published, and what the proxy acknowledged.

Metric (Prometheus name) Type Labels
aether_agent_snapshot_tls_clusters gauge pin, reason mesh cluster entries in the current snapshot that are meant to be mTLS: pin="pinned", and pin="unpinned" once per reason. Written on every snapshot, zeros included
aether_agent_xds_acked_tls_clusters gauge pin, reason the same, for the last snapshot whose cluster update the proxy acknowledged. Absent until the first cluster ACK
aether_agent_identity_cluster_unpinned_total counter reason (new) unchanged otherwise; one series per reason, each seeded at zero

No metric carries a cluster name: each gauge is four series per agent and the counter three, whatever the size of the mesh. "N clusters unpinned for reason R on this node" is sum by (node, reason) (aether_agent_snapshot_tls_clusters{pin="unpinned"}).

Published versus acknowledged uses what the ACK tracker already sees. A delta response carries the version of the snapshot it was built from (system_version_info; go-control-plane sets it to the snapshot's version) and the ACK echoes only the nonce, so the tracker now keeps that version with the in-flight response and hands it to an observer on ACK (never on NACK). The cache keeps the pin counts of its last 64 snapshot versions and turns a cluster ACK into the gauge. The two gauges agree at rest, differ while an update is in flight, and stay different for as long as the proxy rejects cluster updates. The agent logs the acknowledged state only when it changes.

What the acknowledged gauge cannot know is written where it is computed and in the runbook: nothing is recorded before the first cluster ACK the agent process sees (an agent that restarts against a proxy already holding the current clusters owes it no update, so there is no ACK until a cluster next changes; absent means "not known", and in that state the proxy holds what the published gauge shows); the ACK names a snapshot version, not the clusters applied; during a hot restart the last ACK from either proxy generation wins.

Why this shape

  • A gauge, not only the counter. The counter grows by the unpinned count on every snapshot, so its rate is clusters times snapshots. It can say a snapshot went out unpinned; it cannot say how many clusters are unpinned now, or that the number came down.
  • Cost of a snapshot build. The report is classified inside the pass over the cluster entries under clusterMu.RLock that collects the snapshot's clusters (one pass fewer than main, and the counts are of exactly the clusters that version carries). The counts are a fixed-size value, names are collected only for unpinned entries, the history is a fixed ring, and the gauges' attribute sets are built once at registration. TestPinReportCostsNoAllocationPerCluster holds the pass over 500 pinned clusters to zero allocations. The cause is rendered with the pin, inside the existing mTLS render memo (agent: a registry refresh rebuilds every cluster entry as new protos, so the snapshot version memo never reuses them (refresh still ~400 ms p99 at 200m) #1115), so nothing new is computed per refresh. No lock is added to a build path except the history's own leaf mutex; depMu is not touched. The ACK path takes that leaf mutex and nothing else, so the xDS stream never waits on a build.
  • The pin state is remembered before SetSnapshot, because SetSnapshot is what lets a proxy acknowledge the version.
  • One definition. pinState is the single decision the line, the counter and the gauges are built from. TestRuntimePinReportAgreesWithTheBuildTimeGate puts a snapshot the real cache generated (HTTP, port aliases, TCP floor and per-port, UDP, QUIC twins, a probe cluster) through the build-time gate of //agent/test/envoy_validate and requires the same answer by cluster name, so the two cannot drift apart again as they did in agent: "mesh clusters published with no server-identity SAN pin" logged six times in 16 s during a service roll #1393. For that the gate's walk is exposed per cluster (MeshClusterPins); UnpinnedMeshClusters runs on the same walk and returns what it did.
  • No generated xDS resource changes. //agent/test/envoy_validate/... passes unchanged.

The soak gate (e2e/soak/prober-grade.sh), changed in this PR

The UNPINNED gate reads the counter by name and sums every series, so it keeps working on the new shape with no change: with the new fixture and the old script the verdict was already FAIL increase=2. Changed here, with its fixtures and harness_test.sh:

  • a new line UNPINNED reason=<reason> count=N nodes=… for each reason that moved (reason=- for a series from an agent before this change);
  • the reset fixture's rolled agent now exports the three per-reason series, next to old agents that export one (an upgrade roll); the clean fixture is entirely the new shape (15 series, PASS); born stays the old shape;
  • the gauges are deliberately not graded: a gauge is sampled, and an unpinned window shorter than the export interval is in the counter and may be in no gauge sample.

Evidence

Each behaviour was seen red by reverting the production line it tests, then green; every such edit was reverted and the tree checked clean before the next.

Behaviour Reverted Tests that went red
per-cluster cause in the line pinState returns one cause for all TestUnpinnedClusterReportGivesEachClusterItsOwnCause, TestUnpinnedCauseIsTheRendersNotTheReports, TestTLSClusterGaugeFollowsTheTrustDomainWindow, TestRuntimePinReportNeverMissesWhatTheGateFinds, TestEmptyTrustDomainReportsUnpinnedClusters
bounded names the 20-name cut disabled TestUnpinnedClusterReportBoundsTheNamesPerCause
gauge per reason through a refresh that pins a cluster and one that removes one zero values not recorded (a reason keeps its last value) TestTLSClusterGaugeByReasonThroughAPinAndARemoval, TestCacheMetrics_TLSClusterPins and ten more
no series by cluster name a cluster attribute added to the gauge every gauge test (…carries attributes beyond pin and reason)
the snapshot is in the history before it can be acknowledged remember moved after SetSnapshot TestSnapshotIsInThePinHistoryBeforeItCanBeAcked
a NACK acknowledges nothing the tracker tells the observer on NACK too TestAckObserver_ToldTheSnapshotVersionOfEveryAck, TestAckTrackerFeedsTheAckedPinGauge
the soak grade on the new shape new fixture, old expectations 3 grade reset assertions (series counts and the moved line)

Run on the final tree:

  • bazel test //agent/internal/xds/... //agent/internal/cmd/... //agent/internal/cni/server/... //agent/test/envoy_validate/... //e2e/soak:harness_test: 12 of 12 pass
  • bazel test --config=race on cache_test, cachemetrics_test, ack_test, cmd_test, envoy_validate_test: pass; the new ACK and gauge tests 40 times under race: pass
  • bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...: pass
  • make format-check: pass; make gazelle: no further change
  • go vet with the pinned plain go over the touched packages after make materialize-go (the cache's tests now import agent/test/envoy_validate): clean

Metric names: read-only, on a test cluster, the existing gauge aether.agent.snapshot.clusters is stored as aether_agent_snapshot_clusters and the counter as aether_agent_identity_cluster_unpinned_total with job and node labels, for the node agent and for the edge. The new Prometheus names above are inferred from that, not observed.

Not verified

This has not run on a cluster.

  • The new Prometheus names and label names (pin, reason) are inferred from how the collector renames the existing metrics.
  • That Envoy's CDS ACKs arrive as the tests model them is not measured against a live proxy: the tests drive the real go-control-plane cache and the real tracker, with the nonce stamped by hand.
  • How often the acknowledged gauge is absent after an agent restart on a quiet node is not measured; it is expected, and documented.
  • The whole-module go build ./... was not run locally (only go vet on the touched packages); the CodeQL job does it.

What the first deploy should show, per node agent and for the edge:

  1. aether_agent_snapshot_tls_clusters: four series each, pin="pinned" above zero and the three pin="unpinned" series at 0 at rest. Right after an agent start, reason="trust_domain_unknown" may be above zero for a snapshot or two.
  2. aether_agent_identity_cluster_unpinned_total: three series per agent (reason), all starting at zero in the new pods. A dashboard or rule that sums it is unaffected; one that selects a single series is not.
  3. aether_agent_xds_acked_tls_clusters: present on a node once its proxy has acknowledged a cluster update from the new agent (a proxy roll or any cluster change does it), equal to the published gauge at rest. One INFO line proxy acknowledged mesh clusters, all with a server-identity SAN pin per agent start is expected.
  4. If a WARN line appears, its reason and names should match the gauge's count for that reason.
  5. prober-grade.sh over a window that includes the agent roll: UNPINNED verdict=PASS unless the roll itself published trust_domain_unknown snapshots, which it would now print as UNPINNED reason=trust_domain_unknown ….

Docs

docs/runbook.md, "The unpinned-cluster signal": the four signals, what each reason means and what to do, the gauges and their PromQL, published versus acknowledged. docs/observability/README.md: a metrics reference for the three metrics and the expression an alert would be built on (no rule file ships). e2e/soak/README.md: the gate on the per-reason counter.

An agent wrote this pull request, finishing a branch another agent had started.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…cause, and gauges record the SAN-pin state published and acknowledged (#1424, #1425)

The WARN `mesh clusters published with no server-identity SAN pin` picked
one reason for the whole line from the trust domain at report time. The
cause is now recorded by the render that left the pin empty and each
cluster is named under its own: one line per reason (a closed set of
three), at most 20 names per line.

aether.agent.snapshot.tls_clusters{pin,reason} is the number of mesh
cluster entries pinned and unpinned in the current snapshot, per reason,
written on every snapshot with zeros included.
aether.agent.xds.acked_tls_clusters has the same series for the last
snapshot whose cluster update the proxy acknowledged: the ACK tracker
now carries a response's system_version_info to an observer, and the
cache keeps the pin counts of the last 64 snapshot versions.
aether.agent.identity.cluster_unpinned gains the reason attribute.

No metric carries a cluster name. A snapshot build makes the same single
pass over the cluster entries as before and allocates nothing for it on a
node where every cluster is pinned.

The soak grade (prober-grade.sh) sums the counter over every series as
before and now also prints the count per reason.

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 00:25
@bpalermo bpalermo added enhancement New feature or request observability Metrics, logs, profiles, alerts labels Oct 9, 2026

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

Pin counts can race cluster mutation and be associated with a snapshot containing different resources.

2 open findings
What changed in this PR

Adds cause-specific SAN-pin diagnostics and gauges for published versus proxy-acknowledged cluster state.

Changes:

  • Records and reports per-cluster unpinned causes.
  • Tracks snapshot pin counts through xDS ACKs.
  • Updates soak grading, tests, fixtures, and operator documentation.
File Description
e2e/​soak/​testdata/​prober-grade/​reset/​unpinned.window.json Models mixed-version counter series.
e2e/​soak/​testdata/​prober-grade/​clean/​unpinned.window.json Adds per-reason window fixtures.
e2e/​soak/​testdata/​prober-grade/​clean/​unpinned.start.json Adds per-reason start fixtures.
e2e/​soak/​README.md Documents reason-aware grading.
e2e/​soak/​prober-grade.sh Reports increases by reason.
e2e/​soak/​harness_test.sh Tests reason-aware grading output.
docs/​runbook.md Documents SAN-pin signals and remediation.
docs/​observability/​README.md Adds metric reference and PromQL.
agent/​test/​envoy_validate/​validate_test.go Updates helper reference.
agent/​test/​envoy_validate/​builders.go Exposes per-cluster TLS pin classification.
agent/​test/​envoy_validate/​BUILD.bazel Permits cache tests to use validation helpers.
agent/​internal/​xds/​cache/​trustdomain_test.go Updates reason assertions.
agent/​internal/​xds/​cache/​snapshot.go Associates pin counts with snapshot versions.
agent/​internal/​xds/​cache/​pinreport.go Implements pin classification and reporting.
agent/​internal/​xds/​cache/​pinreport_test.go Tests reporting, gauges, and validation parity.
agent/​internal/​xds/​cache/​pinhistory.go Tracks acknowledged snapshot pin state.
agent/​internal/​xds/​cache/​pinhistory_test.go Tests history and ACK behavior.
agent/​internal/​xds/​cache/​mtls.go Records SAN-pin causes during rendering.
agent/​internal/​xds/​cache/​cachemetrics/​cachemetrics.go Adds reason labels and TLS-cluster gauges.
agent/​internal/​xds/​cache/​cachemetrics/​cachemetrics_test.go Tests metric shape and values.
agent/​internal/​xds/​cache/​cache.go Stores pin metadata and history.
agent/​internal/​xds/​cache/​BUILD.bazel Registers new sources and dependencies.
agent/​internal/​xds/​ack/​tracker.go Exposes acknowledged snapshot versions.
agent/​internal/​xds/​ack/​tracker_test.go Tests ACK observer semantics.
agent/​internal/​cmd/​root.go Wires node-agent ACK observations.
agent/​internal/​cmd/​edge.go Wires edge ACK observations.

🧠 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/snapshot.go Resolved
Comment thread docs/runbook.md Resolved
…at collects the snapshot's clusters; the runbook says what no_namespace_metadata means before the node SVID (#1425)

The report was read in a second pass, later in the build. A registry reload
or an identity change landing in between would have filed the pin state of
clusters the proxy was never sent under the snapshot's version, and a cluster
ACK of that version would have published it as acknowledged. It is now
classified in the pass that collects the cluster resources, which also
removes the separate pass.

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.

🔵 Needs a closer look

Security-sensitive xDS acknowledgement telemetry spans concurrency, metrics, and operator semantics without live-cluster verification.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request observability Metrics, logs, profiles, alerts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agent: nothing records the SAN-pin state a proxy actually held agent: the unpinned-cluster warning gives one reason for all the clusters it names

2 participants