Skip to content

fix(agent): a snapshot whose set returned an error is reported as the one served, and a removed cluster's record is kept by time as well as by builds (#1549, #1551, #1550, #1563) - #1608

Merged
bpalermo merged 7 commits into
mainfrom
fix/acked-pin-followups
Oct 9, 2026

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Closes #1549
Closes #1551
Closes #1550
Closes #1563

Four follow-ups to #1528, based on 77f9e8b7.

#1549: a snapshot whose set returned an error is the one served

Checked in the module source (go-control-plane v0.14.0, pkg/cache/v3/simple.go): SetSnapshot stores the snapshot as its first step. It can return an error only after that, from answering the watches that were open: respond and respondDelta return context.Canceled when the context SetSnapshot was called with ends before the watch's channel takes the response. Its other error, building the version map, cannot happen for a snapshot whose map fillVersionMap already built (ConstructVersionMap returns at once on a non-nil map).

generateSnapshot returned on that error before the report of the snapshot. Now, whatever SetSnapshot returned:

  • logIdentityBindings, logInboundIdentityBindings and reportClusterPins (the published gauge, its WARN and its counter) run, with the version of the installed snapshot. The pin report is of the build's own read of the cluster map. The two binding logs read the cache's maps when they run, on this path as after a SetSnapshot that returned nil, so a change a mutator made since the build read them is named under this version; a SetSnapshot that waits on a watch makes that window longer (review round 1, not changed here).
  • The error is logged at WARN as snapshot installed, but an open watch was not answered from it, and is still returned, as snapshot <v> is installed, but an open watch was not answered from it: … instead of failed to set snapshot: …. Callers, the Generated metric and the span see an error as before.

Before, the skipped lines and the gauge were made up for by the next build, under that build's version.

Not changed: an open watch that was not answered stays open. It is answered by a later SetSnapshot unless its stream replaces or cancels it first.

#1551: the record of a removed cluster is kept by time as well as by builds

The record of an entry that left the snapshot was dropped by the third build without it. The step it has to cover, from go-control-plane building a response to the stream writing it, is a wait in the stream's channel, and the number of builds in that wait depends on how fast the node changes.

The record is now kept while either fewer than three builds without the entry have run (goneBuilds, unchanged) or less than one minute has passed since the first of them (goneAge). It is dropped by the first build after both, or by a later answer about that cluster.

  • It is a superset of what was kept before: no record is dropped earlier than it was.
  • Memory: the age bound applies only while the records that are not of an entry of the newest snapshot number at most 1,024 (maxAgedRecords). A build that finds more keeps none of them by age, and they fall back to the build bound for that build; an answer that releases a record while there are more than 1,024 of them, that one counted, does not keep it by age either (review round 1). The bound is inclusive: with exactly 1,024 the age bound applies (review round 2). So at most 1,024 records are kept by age alone at any time. They stay until the first build, or answer about them, after the minute has passed.
  • The clock is injected (ackedPins.now, nil is time.Now); the tests move it by hand.

The new bound. The ACK of a cluster is still not counted when its response is written after the record was dropped: later than three builds without the entry and later than one minute after the first of them, or earlier than the minute when more than 1,024 such records were being kept. As before, the proxy's next opening statement names such a cluster. go-control-plane still has no "a response was built" hook, so this is a bound and not a guarantee.

Not changed: the same step for a cluster that is rebuilt instead of removed is still bounded by a count (offeredVersions, three versions).

#1550, #1563: docs

  • The two annotations that read "1 mesh cluster entries" (AetherMeshClusterUnpinned and AetherMeshClusterPinPending descriptions) are reworded so that the number is not the subject of a sentence. The four expected annotations in agent-pin-alerts_test.yml follow.
  • agent-pin-alerts.yml, registrar-alerts.yml and the README no longer say this repository has no promtool or that CI does not run the rule test. They name //:observability_rules_test. For registrar-alerts.yml the comment says what that target does for it: promtool check rules, and no unit test here. In the README I found one such statement (and a bare promtool command beside it), not the two the issue mentions.
  • docs/runbook.md: the two points above, in "The unpinned-cluster signal".

Contract

The external-harness contract does not change (version stays 2, no entry edited).

Red, then green

Seen failing before the fix, with only the new names added so that the test compiles:

  • TestASnapshotWhoseSetReturnedAnErrorIsReportedAsTheOneServed: the published gauge still showed the previous snapshot (0 unpinned, expected 1), and no line named the unpinned cluster. The test stops there, so the binding-line assertions were first seen failing in the mutation run below.
  • TestAckedPinGaugeCountsAClusterWhoseResponseWaitedManyBuildsToBeWritten: 0 unpinned where the proxy had accepted one.
  • TestAckedPinsKeepAGoneClusterForAWhile (three of its cases) and TestAckedPinsKeptByAgeAreCapped ("at the cap").

Mutations, one at a time, each caught and reverted:

mutation caught by
on a set error: the pin report skipped; the outbound lines skipped; the inbound lines skipped; no WARN line; the old error text; the error swallowed TestASnapshotWhoseSetReturnedAnError… (the last also by TestAckedPinsKnowASnapshotWhoseSetReturnedAnError)
the age is ignored; the first-missing time is never noted; the clock is ignored the three new tests, and for the clock ten tests in all
the first-missing time is not reset when the entry returns; it is reset at every build TestAckedPinsKeepAGoneClusterForAWhile (the second also by nine others)
the age bound is inclusive …ForAWhile, …WaitedManyBuildsToBeWritten
no cap; cap off by one; the cap counts entries instead of records TestAckedPinsKeptByAgeAreCapped
an accepted removal, the end of a delivery, or a restatement drops by builds alone …ForAWhile (the last two survived at first; two cases were added for them)

With the change: //agent/internal/..., //:observability_rules_test and //test/harnesscontract/... pass; --config=race --build_tests_only passes on //agent/internal/xds/cache:all; the new and changed tests pass 50 runs; lint with fail_on_violation on the package and make format-check are clean.

Review round 1

Two threads on f631e73d, answered in 679b8aad, both resolved.

  • The cap did not hold between builds. True. A record that outlived its entry because it was held or in flight, and was released by an answer inside goneAge, was kept by age whatever the number of such records. The three answer paths now ask what the build asks (byAgeLocked). TestAckedPinsKeptByAgeAreCappedWithoutABuild covers each path; four more mutations (each path ignoring the cap, the build not recording its count), caught and reverted.
  • The binding logs read the live maps, not the installed snapshot. True of every build, not only of the error path, and not changed here: capturing the views with the snapshot changes how both logs work and reaches into listener.go. The comment in generateSnapshot claimed more than that and is corrected.

Review round 2

Two threads on 679b8aad, one point, answered in the head commit: the comment on maxAgedRecords and the runbook said an answer drops a released record "while there are that many", which read as "at 1,024". The cap is inclusive (byAgeLocked is <=, and "at the cap" keeps all 1,024); both now say "more than 1,024, the released one counted". No code change. origin/main is merged in.

Tests of #1528 whose setup changed

The window is now two bounds, so tests that built past it move the clock too. No assertion was removed.

  • buildPastTheGoneWindow moves the acknowledged state's clock on by goneAge before its builds.
  • TestAckedPinsAreBoundedByTheClusters, TestAckedPinsKeepAGoneClusterForAFewBuilds, TestAckedPinsStatedClustersWithNoRecord: a hand-moved clock, builds one goneAge apart, same assertions.
  • TestAckedPinGaugeKeepsAClusterWhoseRemovalWasRejected: its last assertion (the record is gone once the removal is accepted) now builds past the window first.

Not verified

  • Nothing was run on a cluster or against a real proxy. agent/internal/xds/ack/tracker.go is not touched.
  • How long a response really waits between being built and being written was not measured; one minute is a choice, not a measurement.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

… one served, and the record of a removed cluster is kept by time as well as by builds (#1549, #1551, #1550, #1563)

generateSnapshot treated an error from SetSnapshot as "not set". The pinned
go-control-plane (v0.14.0) stores the snapshot first and can fail only
afterwards, while answering the watches that were open, so the snapshot is
served. The published pin gauge, its WARN and counter, and the outbound and
inbound identity-binding lines now run whatever SetSnapshot returned. The
error is logged under its own message and returned with its own text.

The acknowledged pin state kept the record of an entry that left the snapshot
for three builds. It is now also kept for one minute from the first build
without the entry, however many builds run, for at most 1,024 such records.

Docs: two alert annotations no longer read "1 mesh cluster entries", and the
statements that CI does not run the rule tests are removed.

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 22:19
@bpalermo bpalermo added the observability Metrics, logs, profiles, alerts label 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

Binding reports can describe the wrong snapshot, and answer paths can bypass the new memory cap.

2 open findings
What changed in this PR

Fixes snapshot reporting after SetSnapshot errors, extends removed-cluster ACK tracking by time, and updates observability documentation.

Changes:

  • Reports installed snapshots even when open-watch delivery fails.
  • Adds a capped one-minute retention window for removed cluster records.
  • Corrects alert annotations and promtool documentation.
File Description
agent/​internal/​xds/​cache/​snapshot.go Handles post-install watch errors.
agent/​internal/​xds/​cache/​ackedpins.go Adds time-based record retention.
agent/​internal/​xds/​cache/​ackedpins_test.go Tests snapshot errors and retention.
docs/​runbook.md Documents updated behavior.
docs/​observability/​README.md Corrects rule-test instructions.
docs/​observability/​agent-pin-alerts.yml Improves alert wording and test notes.
docs/​observability/​agent-pin-alerts_test.yml Updates expected annotations.
docs/​observability/​registrar-alerts.yml Corrects promtool CI documentation.

🧠 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 agent/internal/xds/cache/snapshot.go Resolved
…say what the binding logs read (review round 1)

An answer that released a record inside goneAge kept it by age whatever the
number of such records, until the next build. Every path that can leave a
record with only its age to keep it now asks the same question the build asks.

The comment in generateSnapshot said the report after SetSnapshot describes the
snapshot the cache serves. That holds for the pin report; the two binding logs
read the cache's maps when they run, on the error path as on the other.

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 22:45

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 fixes are consistent with the stated contracts and include focused regression and boundary coverage.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 9, 2026 23: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.

🟢 Approval recommended

The implementation is well tested; only minor inclusive-cap documentation corrections remain.

2 open findings

🧠 Review effort: Balanced

Comment thread agent/internal/xds/cache/ackedpins.go Resolved
Comment thread docs/runbook.md Resolved
bpalermo and others added 3 commits October 9, 2026 20:09
…d 2)

The comment on maxAgedRecords and the runbook said an answer drops a released
record "while there are that many". byAgeLocked keeps a record by age with
exactly maxAgedRecords such records and stops above that; both say so now.

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 23:10

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 implementation matches the documented behavior and includes comprehensive boundary and regression coverage.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 9, 2026 23:29

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 implementation matches the stated behavior and includes comprehensive boundary and regression coverage.

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

observability Metrics, logs, profiles, alerts

Projects

None yet

2 participants