Repository navigation
fix(agent, observability): a caller's ended context no longer leaves a watch unanswered, binding lines are of the snapshot they name, and an unknown pin state has a gauge and an alert (#1509, #1616, #1619, #1620, #1621) - #1625
Conversation
…a watch unanswered, binding lines are of the snapshot they name, and an unknown pin state has a gauge and an alert (#1509, #1616, #1619, #1620, #1621) #1619: with go-control-plane v0.14.0 no stream can leave its response channel full, so a proxy that stops reading cannot stall a snapshot build. Held by tests that run the cache under the library's stream handlers. #1620: SetSnapshot is called under a context that keeps the caller's values and not its cancellation, bounded by 5 s. With the caller's context, one that had already ended made the answer to each open watch a random choice. A build that could not answer a watch returns ErrWatchNotAnswered. #1621: the identity-binding lines are made from the snapshot's own listeners and secrets and from the build's read of the cluster map, joined to the owning pods by listener identity. #1509: aether.agent.xds.acked_tls_clusters_unknown counts the clusters the proxy holds whose pin state the agent cannot determine, and AetherProxyPinStateUnknown fires on it after 15 minutes. #1616: the rule file and the README say what the figure in an annotation adds up. 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
Binding logs can name unpublished clusters, and metric callbacks can emit mutually inconsistent gauge states.
2 open findings
What changed in this PR
Hardens xDS snapshot publication, identity-binding logs, and unknown pin-state observability.
Changes:
- Decouples watch delivery from caller cancellation and adds a bounded timeout.
- Logs bindings from snapshot-associated resources.
- Adds an unknown pin-state gauge, alert, documentation, and tests.
| File | Description |
|---|---|
docs/runbook.md |
Documents snapshot and metric behavior. |
docs/observability/README.md |
Documents the new gauge and alert. |
docs/observability/agent-pin-alerts.yml |
Adds the unknown-state alert. |
docs/observability/agent-pin-alerts_test.yml |
Tests alert behavior and aggregation. |
agent/internal/xds/cache/udspolicy.go |
Handles installed-snapshot errors correctly. |
agent/internal/xds/cache/snapshot.go |
Adds bounded watch delivery and snapshot-based reporting. |
agent/internal/xds/cache/snapshot_watch_test.go |
Tests watch delivery behavior. |
agent/internal/xds/cache/quicpublish.go |
Avoids misreporting installed snapshots as failures. |
agent/internal/xds/cache/pinreport.go |
Tracks mTLS entries per build. |
agent/internal/xds/cache/inboundidentitybinding.go |
Uses snapshot-associated inbound resources. |
agent/internal/xds/cache/identitybinding.go |
Accepts build-derived outbound bindings. |
agent/internal/xds/cache/gamma.go |
Handles installed-snapshot errors correctly. |
agent/internal/xds/cache/cluster.go |
Collects mTLS entry names during cluster reads. |
agent/internal/xds/cache/cachemetrics/cachemetrics.go |
Adds the unknown pin-state gauge. |
agent/internal/xds/cache/cachemetrics/cachemetrics_test.go |
Tests unknown-gauge lifecycle. |
agent/internal/xds/cache/cache.go |
Adds reusable tracking buffers and timeout state. |
agent/internal/xds/cache/BUILD.bazel |
Registers new sources, tests, and dependency. |
agent/internal/xds/cache/bindingview.go |
Introduces snapshot-listener binding views. |
agent/internal/xds/cache/bindinglog_test.go |
Tests binding-log snapshot attribution. |
agent/internal/xds/cache/ackedpins.go |
Reports the unknown-cluster count. |
agent/internal/xds/cache/ackedpins_test.go |
Tests unknown state and timeout errors. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟡 Changes recommended
The new metric lacks the required external contract, its paired gauges can produce inconsistent scrapes, and one regression test can hang indefinitely.
6 open findings
Add new agent pin metric to the external harness contract · New Bound callback receive and always release test resources · New Report only mTLS clusters actually included in the snapshot Snapshot acknowledged and unknown gauges atomically in one callback Document bounded-record path to unknown pin state · New Clarify unknown state does not prove update rejection · New
🧠 Review effort: Balanced
…ines name cluster resources, the unknown gauge is a contract entry, bounded test receives, the unknown state claims no rejection Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…ermo/aether into fix/snapshot-build-pin-alert-cohort
There was a problem hiding this comment.
🟡 Changes recommended
The CNI ADD path still reports ErrWatchNotAnswered as a hard failure despite the snapshot being installed.
1 open finding
6 resolved since last review
Bound callback receive and always release test resources Add new agent pin metric to the external harness contract Report only mTLS clusters actually included in the snapshot Snapshot acknowledged and unknown gauges atomically in one callback Clarify unknown state does not prove update rejection Document bounded-record path to unknown pin state
🧠 Review effort: Balanced
…n open watch was not answered from it (#1620) (#1631) Since #1625 a snapshot build that could not hand a response to an open watch within its bound returns cache.ErrWatchNotAnswered: the snapshot is installed and served. The CNI server still read it as a failed build. Every caller of the snapshot cache in agent/internal/cni/server now passes the mutator's error through one helper. For the sentinel it logs a WARN, adds one to aether.agent.cni.snapshot_watch_unanswered{aether.snapshot.caller} and returns nil; every other error is returned unchanged. - CNI ADD: answered with success instead of Internal, so the runtime no longer tears down and retries a sandbox whose listeners are published. - CNI DEL and the ghost sweep: already best-effort; they no longer log that the listener was not removed when it was. - surge takeover: the step is no longer logged as failed for listeners that are installed. The server holds the cache behind a three-method interface so a test can return the sentinel without waiting out the cache's 5 s bound. Closes #1620 Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Opus 5.5 <[email protected]>



Closes #1509
Closes #1616
Refs #1619 (shown not to be reachable; no fix), #1620 (the reachable cause is fixed; the CNI caller's handling is left) and #1621 (fixed up to a bound that needs
listener.go). None of the three is closed by this pull request.Five issues about the snapshot build and the pin alerts, based on
7fd7fd5d.#1619: one unread watch stalling every build. Not reachable with the pinned server
Read in the module source (
go-control-planev0.14.0) and held by tests that run the agent's cache under the library's own stream handlers.SetSnapshothands each open watch its response on a channel the stream owns and waits for room in it. There is always room:pkg/server/delta/v3): one channel for all types, capacity 20 (twice the resource types the library knows). A watch is answered once and removed. The stream opens the next watch of a type only when it handles the proxy's next request for it, and it empties the channel before it handles any request. So the channel holds at most one response per type that had a watch open, plus the answer to the request being handled: 7 for the six types the agent serves, 11 for a stream that watched every type the library knows.pkg/server/sotw/v3, the per-secret SDS streams): a new channel of capacity 1 for every request, and a watch is answered once. (The agent builds the server without the ordered-ADS option, whose stream shares one channel of capacity 10.)A proxy that stops reading blocks the stream's goroutine in
Send. That goroutine then takes no request, so it opens no new watch, and the build has nothing more to hand over.The tests (
snapshot_watch_test.go, all pass on7fd7fd5dtoo, which is the point):TestABuildDoesNotWaitOnAProxyThatStoppedReadingTestABuildDoesNotWaitWhenTheStreamIsBetweenARequestAndItsWatchTestABuildDoesNotWaitOnAStuckSecretStreamSendin these tests blocks from the first byte: stricter than a real proxy, which has a flow-control window to fill first.What this does not cover. The 300 s hang seen while writing #1608 was a watch made by hand on an unbuffered channel, which no stream of the server makes. The argument is about v0.14.0: a later version that sizes or drains its channels differently fails these tests. Not run against a real Envoy.
No deadline counter and no cancelled-watch machinery was added for this. See #1620 for the one line that does bound the wait, and why.
#1620: a build reported as failed although the snapshot was installed. Real, with a different cause than the issue assumed
With #1619 unreachable, the error has one way to happen, and it does not need a stuck watch.
SetSnapshotselects, for each open watch, between the watch's channel and the end of the context it was given. With a context that has already ended, both are ready and Go picks at random. The first watch that loses ends the set: the build returns an error for a snapshot that is installed, and that watch and the ones after it stay open and unanswered, so the proxy is not sent the change until the next build.AddPodis called with the CNI ADD's RPC context (agent/internal/cni/server/pod.go), which ends when the plugin's call is abandoned.Seen failing on
7fd7fd5d:TestACallersEndedContextDoesNotLeaveAWatchUnanswered(a real delta stream with six open watches whose proxy reads everything; a build under an ended context returned the error at the first build).The change, in
snapshot.go:SetSnapshotis called undercontext.WithoutCancel(ctx)with a timeout (defaultWatchAnswerTimeout, 5 s). What the proxy is sent no longer depends on the caller's context. The timeout replaces the caller's context as the only way out of a wait; per agent: one unread xDS watch can stall every snapshot build on the node #1619 it is not expected to elapse.ErrWatchNotAnswered(wrapped, with the library's error), so a caller can tell "installed, a watch not answered" from "not built" witherrors.Is.regenerateAllHTTPListeners,rebuildIdentityDerived,regenerateAllAppDeliveryClusters, the QUIC publisher) no longer log an installed snapshot asfailed to regenerate snapshot; the build has already logged the unanswered watch at WARN. The mutators that return the error (AddPod,RemovePod, the cluster and secret setters) return it wrapped, unchanged otherwise.What this does for #1620, and what is left (review round 2). Done: a caller's ended context no longer leaves a watch unanswered or makes the build return an error, and a caller can tell "installed, a watch not answered" with
errors.Is(err, cache.ErrWatchNotAnswered). Left: the CNI ADD path (agent/internal/cni/server/pod.go) still turns everyAddPoderror intocodes.Internal, so if the 5 s bound does expire, a pod whose snapshot is installed is reported as failed and retried. That false failure now needs the bound to expire, which #1619 shows no stream of the pinned server causes; it is still the one #1620 describes, and it stays open until the CNI caller treatsErrWatchNotAnsweredas installed.agent/internal/cni/server/is not touched here.#1621: identity-binding lines under the wrong snapshot version. Fixed for what a line names; one bound stated
The two logs read the cache's maps after
SetSnapshot. Seen failing on7fd7fd5d:TestBindingLinesAreOfTheSnapshotTheyNamestops a build insideSetSnapshot, adds a pod, a cluster and a secret meanwhile, and lets it go. The first version's lines named the late pod and the late cluster and said the late secret was served; the build that published them logged nothing.Now the lines are made from the snapshot's own resources:
bindingView), joined by identity: a pod is named only when the very listener proto its entry held is one of the snapshot's listeners.So no line names a pod, a cluster or a served secret that the snapshot of its version does not carry.
What is not exact, and why this says Refs:
Listeners()are two reads of the listener map, a few statements apart. An entry written between them is in the snapshot and is first named by the next build. A pod that was already named and is rebuilt in that gap is left out of this build's table and named again by the next one. Closing it needsmeshListeners()to return the owners under its own lock, which is inlistener.go.localWorkloads) is not a resource of any snapshot. It is read during the build instead of after the set.Behaviour changes:
clusterattribute of an outbound binding line is the cluster's resource name. It was the entry's map key, which for a service's default entry is the service key and not the FQDN the cluster is published under (review round 1). The TCP floor clusters are not named, as before: floor entries hold no mTLS-injected cluster.#1509: the divergence alert goes silent when the agent restarts while the proxy rejects. Still applied after #1528; fixed with a gauge and a rule
Checked first: the promtool case on
mainasserted the silence (…silences the divergence rule), andTestAckedPinGaugeWhenTheAgentRestartsWhileTheProxyRejectsshows the gauge withdrawn. #1528 made the agent stop writing a wrong count there; it did not make the state visible to a rule.aether.agent.xds.acked_tls_clusters_unknown(storedaether_agent_xds_acked_tls_clusters_unknown, one series per agent, no attribute): the number of mesh clusters the proxy holds whose pin state the agent cannot determine. Zero while the acknowledged gauge is written, the count while it is withdrawn for that reason, absent until a proxy has answered a cluster response of this agent process.AetherProxyPinStateUnknown: above zero for 15 minutes, warning. It says the agent cannot classify what the proxy holds and that the divergence rule is blind for that node. It does not say the proxy holds an unpinned cluster, and it does not say the proxy is rejecting updates: a proxy that accepted a version whose pin class the agent had already dropped from its bounded record produces the same state, with no NACK (review round 1).Seen failing before the fix: the cache test (
the withdrawal is a sample) and the promtool case (AetherProxyPinStateUnknownat 35m: expected one alert, got none).#1616: the pin alerts'
$value. The premise did not ship; the same holds throughpod; documentedThe edge control plane sets no
service.instance.id(only the edge proxy container does), so there is noinstancelabel separating two replicas. Butdocs/observability/metric-labels.mdrecommends promotingk8s.pod.nametopodforaether-edge, and in such a pipeline two co-located edge replicas are two sets of series thatsum by (job, node, reason)adds up. The rule file's header and the README now say what the figure is, and a promtool case holds it (two replicas, one unpinned cluster each: one alert, figure 2). No expression changed.Contract
The external-harness contract gains one entry;
versionstays 2 (a new entry needs no bump, per the README's table).agent.xds_acked_tls_clusters_unknownis added toexternal-harness.yamland to the ids//agent/internal/xds/cache/cachemetrics:cachemetrics_testowns and checks. No existing entry is edited:agent.xds_acked_tls_clustersis written and absent under the same conditions as before.#1566 (the contract lock file) is not merged. When it is, this entry needs its line in the lock file.
Red, then green
Seen failing on
7fd7fd5d(production files of the package checked out at that commit, new tests kept):TestBindingLinesAreOfTheSnapshotTheyName(all four assertions).TestACallersEndedContextDoesNotLeaveAWatchUnanswered(build 1).TestAckedPinGaugeWhenTheAgentRestartsWhileTheProxyRejectsand the promtool case, before the gauge and the rule existed.The three #1619 tests pass on
7fd7fd5d: they show the stall cannot happen.Mutations, one at a time, each run against the tests and reverted (30 in all):
SetSnapshotunder the caller's context againTestACallersEndedContext…TestABuildThatCouldNotAnswerAWatchSaysSosnapshotInstallediserr == nil; is always trueTestCallersThatOnlyLog…(four mutations)TestBindingLinesAreOfTheSnapshotTheyNameservedfrom the cache's secret map; mTLS entries from the cluster map of nowTestBindingLinesNameTheMTLSEntriesTheBuildReadwas added for them)for14m, 16m, 1m;>= 0The two survivors are each one half of the old behaviour. The identity join makes either half alone name nothing the snapshot lacks; what each loses is an omission in the race (a pod removed during the set), which no test here drives.
With the change:
//agent/internal/...,//agent/test/...,//:observability_rules_testand//test/harnesscontract/...pass;--config=race --build_tests_onlypasses on//agent/internal/xds/cache:allandcachemetrics:all; the new and changed tests pass 50 runs at 4 wide; lint withfail_on_violationon//agent/internal/xds/cache/...,make format-checkandmake go-build-plainare clean.Review round 1
Six threads on
fe4c13f5, all fixed, in the head commit.origin/mainis merged in.RegisterCallbackfor both instruments, one read under the mutex.TestAckedGaugesAreCollectedTogether(red first: each gauge had a callback of its own).TestBindingLinesNameClusterResources, the line saidaether-test/echowhere the snapshot carriesecho.aether-test.aether.internal). The names are now those of the mTLS-injected clusters appended in the pass. The floor half of the point cannot happen today (a floor entry holds no mTLS-injected cluster), and the name is now taken after the floor branch, so it cannot start to.bindinglog_test.goare bounded too. The other tests of the file already receive through bounded helpers.Review round 2
One thread on
5aca6816: the CNI ADD path still fails a pod forErrWatchNotAnswered. True, and that package is out of this pull request's reach, so #1620 isRefs, notCloses, and the section above says what is done and what is left. No code change.Tests of #1608 whose setup changed
TestAckedPinsKnowASnapshotWhoseSetReturnedAnErrorandTestASnapshotWhoseSetReturnedAnErrorIsReportedAsTheOneServedmadeSetSnapshotfail with an ended context and an unbuffered watch. An ended context no longer does that, so they set a 50 ms bound and assertErrWatchNotAnswered. No other assertion changed.Not verified
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr