Repository navigation
feat(registrar): export the snapshot content hash as a gauge value; plain divergence rule (#1329) - #1346
Merged
Conversation
…1329) aether.registrar.snapshot.content carries the hash as a label. A content change ends one series and starts another, OTLP has no staleness marker for a series an observable gauge stopped reporting, and Prometheus keeps returning the superseded hash for its 5-minute lookback. #1328 worked around that in the divergence rule with a timestamp() filter. Add aether.registrar.snapshot.content_hash, whose VALUE is the hash: the first 13 hex digits (52 bits) of the content hash, an integer a float64 holds exactly. One series per replica, no label that changes. The conversion lives in common/snapshotversion (ContentHashValue) next to the version parser. The gauge is observed in the same callback, from the same Snapshot.State(), as the revision gauges, on every backend and in every version form. The labelled metric is deprecated and kept for one release so a rule on it keeps working while replicas of both images run. docs: AetherRegistrarSnapshotDiverged is now a plain count of distinct values per (job, revision); the runbook has the by-hand query, the bit budget, how the two metrics arrive, and the two-arm rule for the upgrade. Closes #1329 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
There was a problem hiding this comment.
🟢 Approval recommended
No blocking issues remain in the implementation, regression coverage, or migration guidance.
0 open findings
What changed in this PR
Addresses #1329 by exporting snapshot hashes as gauge values, avoiding stale hash-label series in Prometheus divergence checks.
Changes:
- Adds an exact 52-bit hash conversion and observes it alongside snapshot revisions.
- Adds conversion and metric regression tests.
- Simplifies the divergence rule and documents migration while retaining the old metric for one release.
| File | Description |
|---|---|
| registrar/internal/server/metrics.go | Exports the new gauge and deprecates the labelled metric. |
| registrar/internal/server/metrics_test.go | Tests gauge updates, replica agreement, and backend variants. |
| docs/runbook.md | Documents queries and rolling-upgrade steps. |
| docs/observability/registrar-alerts.yml | Switches divergence detection to gauge values. |
| docs/observability/README.md | Explains the metric and migration. |
| common/snapshotversion/snapshotversion.go | Adds the 52-bit hash conversion. |
| common/snapshotversion/snapshotversion_test.go | Tests conversion, precision, and version forms. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+3576
to
+3577
| `count(aether_registrar_snapshot_content_hash) == count(aether_registrar_snapshot_revision)` | ||
| (every replica that reports a revision reports the value gauge). |
bpalermo
added a commit
that referenced
this pull request
Oct 11, 2026
…auge is removed (#1667) The labelled info gauge aether.registrar.snapshot.content{content_hash} (Prometheus aether_registrar_snapshot_content) was deprecated in chart 2.4.12 (#1329, #1346) in favour of aether.registrar.snapshot.content_hash, which carries the hash as its value and is what the shipped rule AetherRegistrarSnapshotDiverged reads. Deprecated in 2.4.x means removable from 2.5.0 on; the "chart 2.6.0 at the earliest" written beside it by #1658 was one minor too cautious and is corrected here. - registrar: the instrument, its content_hash attribute key and the helper that observed both gauges are gone; the value gauge and the revision gauges are untouched. A test asserts the exported metric set does not contain the name, and that no gauge data point carries a content_hash attribute. - docs: the runbook's transitional `or` arm and its order of work, the "Deprecated" sections of the runbook and docs/observability/README.md, and the upgrade comment in registrar-alerts.yml are replaced by a short account in the past tense. The shipped rule and its promtool tests never read the metric and are unchanged. - chart 2.5.9: a runbook section says what an operator sees (a rule or a dashboard still reading the metric returns no data, silently), the query to use instead, and closes the row of the "Chart 2.5.7" deprecation table. The upgrade rolls the registrar Deployment (new image); no template changed. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Closes #1329
What
New registrar gauge
aether.registrar.snapshot.content_hash(Prometheus:aether_registrar_snapshot_content_hash) whose value is the snapshot's content hash. One series per replica, no label that changes, so a content change moves the value and nothing is left in Prometheus's 5-minute lookback.[0, 2^52).snapshotversion.ContentHashValuedoes the conversion, next to the existing version parser (no new parser: it takes the hashContentHash()/State.ContentHashalready yield).printf '%013x' <value>is the start of the<hash>in a version string.ObserveSnapshotcallback, from the same singleSnapshot.State()read as the revision gauges, so the hash and revision of one collection always describe the same contents. The hash itself is still computed under the mutation lock; nothing new runs there.<rev>.<hash>, dirty<rev>+<hash>andhash:<hash>all report the hash of what is served now.snapshot_revisionis not, so the rule returns nothing there. Two replicas can differ briefly on that backend because health derives from each replica's clock, so it is for reading by hand and is not alerted on.aether.registrar.snapshot.content{content_hash}is still exported, marked deprecated in its description, the code comment, the README and the runbook. Remove it in the release after this one.The rule
for: 3m, same labels and alert identity ({job, revision}) as #1328. Notimestamp()filter.Do the two metrics' timestamps matter?
No. What I checked:
go.opentelemetry.io/otel/sdk/metricv1.47.0):pipeline.produceruns every callback first, then collects each aggregation;lastvalue.gostamps each instrument's data point with its ownnow(). So revision and hash come from one callback (oneState()), with timestamps microseconds apart.timestamp(aether_registrar_snapshot_revision) - timestamp(aether_registrar_store_revision)per replica peaked at 4 ms over 24 h. The stamps are not identical, so a rule that paired ontimestamp()equality across two metrics would be wrong.batch(nosend_batch_max_size, so it does not split a request) ->otlphttp-> Prometheus's OTLP receiver. I did not trace the receiver's commit path in the Prometheus source; I am relying on its documented one-appender-per-request behaviour.for: 3m(kept for the RPC-between-syncs window) covers that.Rolling upgrade
A rule on the new metric cannot see a replica on an older image: before the registrar is upgraded it is empty, and mid-roll it compares only the new replicas. So
docs/observability/registrar-alerts.ymlcarries the plain rule, and the runbook gives a two-arm form (new or #1328, oneunless) for the upgrade. Both arms return{job, revision}, so one divergence is one alert. Order: deploy the two-arm rule, upgrade the registrar, drop the second arm, then take the release that removes the labelled metric.GitOps mirror: not opened
bpalermo/k8s-talos-main#152 (which adds this alert in its #1328 form) is still open (checks green, mergeable), so I did not open a PR against that repo. The patch below applies on top of #152's head (
9b33a0c); apply it after #152 merges. It switches the live rule to the two-arm form and adds tests.Validated the way that repo's CI does, with promtool 3.6.0, on #152's head plus the patch:
kubectl kustomize clusters/talos-main: exit 0promtool check rules: 67 rules, SUCCESSpromtool test rules: SUCCESSk8s-talos-main patch (on top of #152)
Proof (this repo)
bazel test //registrar/internal/server:all //common/snapshotversion:all //registry/... --test_arg=-test.short: 7/7 passbazel test --config=race //registrar/internal/server:server_test //common/snapshotversion:snapshotversion_test: 2/2 passbazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...: cleanmake format-check: clean;make gazelle: no changepromtool check rules docs/observability/registrar-alerts.yml(3.6.0): 1 rule, SUCCESS. The plain rule also passed a scratch promtool test (agree, adjacent values diverge, both change, lag, pending intent, no revision); that test is not in this repo, which has no promtool in its build.New unit tests: truncation and rejection cases for
ContentHashValue, float64 round trip at the top of the range, the same value from all three version forms, one label-free series whose value follows the contents, equal values on two replicas for equal contents reached by different paths, different values for different contents at one revision, the dirty form, and the kubernetes (hash:) case.No chart change.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr