docs: document datastore_connected and say what it actually reports #2243
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2243"
general
weight: 0.35
KaivalyaMDabhadkar
Summary
datastore_connectedis not listed indocs/METRICS.md, the catalogue a reader goes to. #1843 touched eleven files and none of them was that one, so for most of this metric's life the only thing describing it has been its own HELP string: "Reports 1 if the datastore watcher has connected, 0 otherwise". (One line indocs/platform-connectors.mddescribes it correctly today, added in #2199 after the confusion below; the catalogue entry is still missing.)Readyhas a single branch onprovider == niland never callsLagState(), and nothing restores the provider to nil (SetWatcher(nil)returns early), so the gauge is 1 from the moment the watcher starts and stays there for the life of the process.The behaviour is right. A watcher that stops after connecting is surfaced by the component exiting —
node-drainer/main.go:298(whose comment reads "Signal a critical failure so the pod exits and Kubernetes restarts it"),fault-remediation/main.go:281,fault-quarantine/pkg/eventwatcher/event_watcher.go:168— which is the path #2020, #2024 and #2040 established, and whichchange_stream_reopens_total's own row inMETRICS.mdalready describes. The gauge simply is not the thing that reports it.Read as written, the HELP invites an alert on
datastore_connected == 0. That alert cannot fire. We wrote one against a fleet, kept it, and found it inert only on readingReady— having first spent a while looking for a pipeline fault, because a gauge that promises connectivity and never drops looks like a gauge whose consumer is broken.It is the readiness probe, in gauge form
Worth saying in the catalogue because it changes what an operator should alert on.
WithReadinessChecktakes a single checker and/readyzis 503 exactly when that checker errors (commons/pkg/server/server.go:301). All three components register this checker and nothing else —server.WithReadinessCheck(readinessChecker)innode-drainer/main.goandfault-quarantine/main.go,mgr.AddReadyzCheck("readyz", readinessChecker.Check)infault-remediation/main.go— and the charts pointreadinessProbe.httpGet.pathat/readyz.So
kube_pod_status_readyalready carries the same answer, with pod and namespace labels, and it still answers when the metrics endpoint itself is down — the case where this gauge is absent rather than 0. #1839 asked for the gauge so that alerting would not have to poll probes, but it never had to: kube-state-metrics exports readiness already.That does not make the gauge wrong to have — it comes from the component's own registry, so it works without kube-state-metrics — but it is not independent information, and the catalogue row now says so rather than leaving a reader to discover it.
Two changes:
docs/METRICS.mdgains a row for it, in the Change Stream Metrics table alongside the siblings it belongs with, plus a note on the section preamble since this one comes fromcommons/pkg/serverrather thanstore-clientand carries noclientlabel. The row says it latches, points atkube_pod_container_status_restarts_totalfor the case the gauge cannot show, and recommendskube_pod_status_readyover it for the case it can.commons/pkg/server/datastore_readiness.gogets three statements corrected: the HELP, the type doc ("reports readiness based on change stream watcher lag state"), and the setter doc ("the LagStateProvider used to determine datastore connectivity"). The setter's new comment saysReadydoes not callLagState, so the next person to work on this does not assume the lag check is already wired.Not in this PR: the name.
connectedreads as "currently attached" and the gauge means "started once", which no comment fully repairs.change_stream_watcher_startedwould put it in the family its siblings occupy, andstartedavoids colliding with the readiness probe this checker also serves. A rename is cheaper than it looks — the metric has noMETRICS.mdentry today and no labels, so there is no documented surface or series shape to migrate — but it still breaks anyone who built on the name, so it wants deciding on its own. The newMETRICS.mdrow records the mismatch so the question does not get lost.Type of Change
Component(s) Affected
Testing
Tests pass locally —
go test ./... -count=1acrosscommonsexits 0: 21 packagesok, no failures, 5 with no test files. This module needs noenvtest, so unlike most of this repository the suite covering the changed file actually ran here,commons/pkg/serverincluded.gofmt,go build ./...andgo vet ./pkg/server/are clean.Manual testing completed — every statement was checked against the code or measured, not inferred from how it ought to work:
Ready's single branch, the absence of anyLagState()call in that file, andSetWatcher(nil)returning early;min_over_time(datastore_connected[30d]) == 1on a live v1.29.0 install, across six pod lifetimes — two generations each offault-quarantine,node-drainerandfault-remediation, so the window includes startups, with no gap incount_over_time;docs/METRICS.mdhas no entry for it, and that #1843's eleven changed files do not include it, which is what left the HELP carrying the description on its own;WithReadinessCheckholds one checker and that each of the three components registers only this one, which is what makes the gauge equivalent to pod readiness.No breaking changes — comments, a HELP string and a documentation table. The HELP text is longer, which changes one
# HELPline in/metricsoutput and nothing else.Checklist
AI assistance was used for this change. Worth knowing where to look closely: the first version of this report claimed the gauge's inability to reach 0 left datastore loss undetected, and re-reading
mainfound the exit guards in all three components, so that claim was wrong and the scope is documentation only. The first version of the HELP text was also written in implementation terms ("has been assigned") before being rewritten for the operator who meets this metric in a dashboard.<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Documentation
Clarified that datastore readiness becomes successful when the change-stream watcher is handed to the readiness checker, before its event loop starts, and does not reflect watcher lag.
Documented that
datastore_connectedremains at1if the datastore is later lost; the component stops and the pod restarts.Specified which components expose the metric, noted that it has no
clientlabel, and recommendedkube_pod_status_readyunless a component-specific signal is needed.<!-- end of auto-generated comment: release notes by coderabbit.ai -->