Repository navigation
fix(registrar): name the snapshot by its contents (store revision); version only at consistent points - #1204
Merged
Merged
Conversation
…stent points The registrar's snapshot version was a per-process counter bumped on every sync and every RPC batch (#1193). A reconnecting agent's last_version went stale on every 5 s poll, so every reconnect paid a full snapshot; and two replicas behind one Service counted independently, so a reconnect landing on the other replica with a coincidentally equal counter skipped a snapshot it needed (silent stale cache). The version now names the contents: - "<rev>": the etcd listing at store revision rev. The sync reads every protocol in ONE Get (registry.RevisionedLister) and takes its header revision. Same revision => same contents on every replica. - "<rev>+<hash>": the listing plus an overlaid write-behind intent or an RPC applied since; the suffix is the content hash, never another replica's clean revision. - "hash:<hash>": backends without a revision. The kubernetes backend does not implement the capability: its listing derives health from the clock and locality from a separate node list, and the Pod list RV moves on any write. The content hash (sha256 over sorted keys + deterministic endpoint encoding) is computed in the mutation's critical section; a token whose embedded hash matches the current contents is current (the marker echoes it). Stamping the version only at consistent points (#1203): FULL_SNAPSHOT and catalog events carry none, SNAPSHOT_COMPLETE does, and a broadcast batch carries it on the last event each watcher receives. With stable versions a stream cut mid-snapshot or mid-batch otherwise left the agent presenting a version it did not fully hold, and the reconnect skipped the resend. Metrics: snapshot.version keeps its series name as the content-change generation; new store_revision, snapshot_revision and an info gauge snapshot.content{content_hash} (one series per replica, observed). The agent's last_version gauge parses the revision before '+'. Fixes #1193 Fixes #1203 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
aether.registrar.watch.starts{resume} makes the reconnect fast path
observable: the share of agent reconnects that skip the full snapshot.
Also remembers the content hash of the last 64 clean revisions so a clean
"<rev>" token is current after the revision moved without a content change
(an agent's re-assert re-Puts what etcd already holds).
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Measured on kind: an agent learns a revision only from an event that reaches it, so a no-op store write (or a change outside a demand-scoped filter) leaves aether.agent.registry.last_version behind a current cache. Say so in the gauge description and the runbook's stored/in-place/applied section. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Oct 4, 2026
…send Review of #1204. HIGH: processStream cleared the cache on the first FULL_SNAPSHOT but kept the resume token, and every non-DataLoss end returned it. With content-addressed versions that token can match again -- a lagging replica, a reverted content, or another replica's revision history -- and the reconnect is served the marker alone onto an empty or partial cache. The agent now drops the token at the cache clear; SNAPSHOT_COMPLETE hands it the new one. Design: the version always embeds the hash -- "<rev>.<hash>" clean, "<rev>+<hash>" dirty, "hash:<hash>" without a revision -- and only the hash decides currency. The 64-revision ring is gone (it aged out under busy etcd traffic, its echoed token never refreshed, and a bare revision assumed revisions are never reused). A token with the current hash under another name gets the catalog and a SNAPSHOT_COMPLETE carrying the CURRENT version (no endpoint events): resume=renamed. The agent gauge parses before '.' or '+'. Documents the O(N) per sync / O(N log N) per mutation hash cost. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Oct 4, 2026
…from the last two days (#1235) - proxy-supervisor: drop "15 MiB / 24 modules" (it links 25 since the OTel 1.47 bump, #1215) and name deps_test + check-proxy-supervisor-deps.sh as the source of truth; that guard asserts forbidden packages and a size ceiling, not a count. - cni: the allow-list budget is 19, not 37 (#1185). Point at the guard's maxModules instead of repeating it; the build-graph script now forbids OpenTelemetry too. The plugin forwards timings to the agent. - mesh-dns: same wording (its guard asserts 30, still correct). - cni/internal: telemetry/ was removed by #1185. - registrar/internal/server: the snapshot version is store revision + content hash since #1204. - Add agent/internal/ownership (proposal 041), common/drain, common/referencegrant, and common/taint (in the node-taint entry). Fixes #1224 Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Fable 5.1 <[email protected]>
This was referenced Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problems
atomic.Uint64. EveryreplaceLockedbumped it, on every sync poll (changed or not), and so did every RPC apply batch.WatchEndpointsskips the full snapshot only whenlast_version == current. So any poll between a stream drop and the reconnect forced a full resend: in practice every reconnect.Design
Backend revision as the version. New optional capability
registry.RevisionedLister(same pattern asDerivedEndpoints, fix(registrar): kubernetes backend releases an agent's write at the next sync, so every replica serves the Pod-derived endpoint (#1145) #1152).Get(it was 3) and takesresp.Header.Revision. The watch-response headers feedStoreRevision(). The per-protocolListAllEndpointsAPI is unchanged.resourceVersion:podHealthdepends onnow()(the registrar (kubernetes backend): the agent's second drain step (UNHEALTHY ~1 s before SIGTERM) reaches only the receiving replica #1144 pool-close deadline), locality comes from a separately cached node list, and the list RV moves on any write in the cluster. The version there is content-addressed, and the lag metrics are etcd-only. This is stated in the capability doc and the runbook.Version format. The content hash is always embedded, and only the hash decides currency. The revision is carried for the lag metrics and is never trusted for equality: a rebuilt etcd restarts at 1, and a binary that decodes a stored value differently derives different contents at the same revision.
<rev>.<hash>rev<rev>+<hash>hash:<hash><hash>is sha256 over sorted keys plus the deterministic proto encoding of each endpoint, truncated to 16 hex. It is computed in the mutation's critical section, at O(N) per sync and O(N log N) per mutation (documented in code). No form parses as a bare integer.Resume decision (
Snapshot.WatchStart, one critical section):current: the token is the current version. The client getsSNAPSHOT_COMPLETEonly.renamed: the token's hash equals the current content hash under another name (the revision moved without a content change, a dirty token re-derived clean, another replica's name). The client gets the service catalog plus aSNAPSHOT_COMPLETEcarrying the current version, with no endpoint events. The agent swaps in an identical catalog and adopts the fresh token.resent: anything else. Full snapshot and catalog.Agent token drop (review HIGH).
processStreamnow clearslastVersiontogether with the cache on the first FULL_SNAPSHOT. A resend cut short therefore reconnects with no token, rather than with one that a lagging replica, reverted contents, or another replica could still match. Without this, that match served the marker alone onto an empty cache.Version only at consistent points (registrar/agent: the watch version is stamped on every event, so a stream truncated mid-snapshot or mid-batch leaves the agent with last_version = V and partial state — a reconnect that matches V skips the resend #1203). FULL_SNAPSHOT and catalog events carry no version;
SNAPSHOT_COMPLETEdoes.Broadcaster.Broadcastputs the batch version on the last event each watcher receives, with unversioned copies built once per event (not per watcher). Old agents already ignore empty versions, so they get the fix for free.Generation.
aether.registrar.snapshot.versionkeeps its series name (no dashboard or alert uses it, see below). It now records a generation that moves only when the content hash changes.New metrics
aether.registrar.store_revisionandaether.registrar.snapshot_revision(observable, etcd only).aether.registrar.snapshot.content{content_hash}: an info gauge. It is observed, so exactly one series per replica is exported and a superseded hash stops being exported.aether.registrar.watch.starts{resume=resent|current|renamed}: the measurement instrument, kept because it is the fast-path hit rate.Agent. The
last_versiongauge parses the part before.or+.hash:never parses.Wire compat. No proto change. Nothing parses the version semantically; the only numeric parses were the two gauges, both handled.
Red, then green
Each test was red on
mainbefore the change:TestSnapshot_NoOpSyncKeepsVersion: two no-op syncs moved the version.TestSnapshot_VersionIsComparableAcrossReplicas: same contents gave different versions; different contents gave the same version ("1").TestWatchEndpoints_TruncatedSnapshotIsResentOnReconnect(registrar/agent: the watch version is stamped on every event, so a stream truncated mid-snapshot or mid-batch leaves the agent with last_version = V and partial state — a reconnect that matches V skips the resend #1203): stream dies after the first FULL_SNAPSHOT event. The reconnect was told it was current.TestWatchEndpoints_TruncatedBatchIsResentOnReconnect(registrar/agent: the watch version is stamped on every event, so a stream truncated mid-snapshot or mid-batch leaves the agent with last_version = V and partial state — a reconnect that matches V skips the resend #1203): stream dies inside an ENDPOINT_ADDED + SERVICE_ADDED batch. Same result.TestWatchEndpoints_CompleteStreamResumesWithoutResend: complete stream, then a no-op sync, then reconnect. It got a full resend.TestClientMetrics_LastVersionIsTheStoreRevision(agent):41+<hash>was not recorded.TestProcessStream_TruncatedResendClearsResumeToken(agent; review HIGH): a non-empty token41.<hash>, a resend cut after the first FULL_SNAPSHOT, the stream ended by transport error, EOF, or server-drain GOAWAY. All 3 subtests were red; the old token survived.New coverage:
TestSync_StoreRevisionIsTheVersion: one read per sync; a revision-only move leaves generation and hash unchanged.TestSnapshot_ReplicasAtOneRevision: same revision with different content gives a differentcontent_hash.TestSnapshot_ContentHashCoversEveryField: the hash comes from the entries, not the revision.TestSnapshot_ApplyDirtiesARevisionedVersion.TestSync_PendingOverlayDirtiesTheVersionUntilObserved(etcd observed path) andTestSync_DerivedReleaseReturnsToTheCleanRevision(fix(registrar): kubernetes backend releases an agent's write at the next sync, so every replica serves the Pod-derived endpoint (#1145) #1152 derived path).TestSync_NoRevisionIsContentAddressed.TestWatchEndpoints_ResumeDecision, with these cases:TestWatchEndpoints_TruncatedResendOntoALaggingReplica: review scenario (2), end to end.TestBroadcast_VersionOnEachWatchersLastEvent.TestMetrics_ObserveSnapshot: exactly onecontentseries after several hash changes.TestMetrics_WatchStarts(resent / current / renamed).TestEtcdRegistry_ListAllEndpointsRevisioned(testcontainers).Existing tests that pinned counter values (
TestVersion,TestReplace,TestApply,TestFullSnapshotEvents,TestGetAllWithVersion,TestSyncer_Start_NoEventsAfterInitialSync, the metrics tests) were rewritten to assert the generation. No test case was removed.A mutation check confirms the dirty and hash-match logic are load-bearing: removing either fails 3 tests.
go_testtargets under//registrar/...and//registry/..., including the agent registry client, are green under--config=race --runs_per_test=10.lint(fail_on_violation,//...) andformat-checkare clean.kind measurement
Measured on the first revision of this branch (versions were bare
<rev>). The drop scenario resolves the same way under the hash-embedded format: same contents give an identical version, socurrent.e2e/drain-propagation.shsetup: etcd backend, 2 registrar replicas, client-a's 4 GET loops running. The source agent's registrar TCP connection was killed withss -K20× (the agent stays up). Replica attachment was read from conntrack before and after each drop. Full-snapshot sends were counted withaether.registrar.watch.starts{resume}, summed over both replicas.Arms:
mainplus that counter only (instrumentation, no behaviour change).The agent image is this branch in both arms; its only change is the gauge parse.
After the runs both replicas reported
snapshot_revision=20,store_revision=20, the samecontent_hash="e5ce0416ae6e28ea", and both agents reportedlast_version=20.Lag metrics through a pod churn (one quic-a replica deleted at t=0, 15 s preStop). Rows are printed only when a value changed; sampling is about every 0.8 s.
GitOps metric-name hits
/home/palermo/code/bpalermo/k8s-talos-main(read-only grep foraether_registrar_*,aether_agent_registry*,snapshot_version): none. No dashboard or alert depends on the redescribed series.Docs
docs/runbook.mdhas a new section, "Stored vs in place vs applied". It covers the three version forms, the PromQL for replica lag, agent lag and divergence, the divergence rule (same revision with a differentcontent_hashand no pending write-behind is a bug), and the kubernetes and upper-bound notes. No chart change.Fixes #1193
Fixes #1203
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr