← Back to Pull requests

docs: document datastore_connected and say what it actually reports #2243

Closed
unknown closed this pull request without merging on Nov 03, 2026 11:51 UTC
View on GitHub
unknown unknown commented on Nov 02, 2026 06:03 UTC
Author

Summary

datastore_connected is not listed in docs/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 in docs/platform-connectors.md describes it correctly today, added in #2199 after the confusion below; the catalogue entry is still missing.) Ready has a single branch on provider == nil and never calls LagState(), 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 which change_stream_reopens_total's own row in METRICS.md already 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 reading Ready — 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. WithReadinessCheck takes a single checker and /readyz is 503 exactly when that checker errors (commons/pkg/server/server.go:301). All three components register this checker and nothing else — server.WithReadinessCheck(readinessChecker) in node-drainer/main.go and fault-quarantine/main.go, mgr.AddReadyzCheck("readyz", readinessChecker.Check) in fault-remediation/main.go — and the charts point readinessProbe.httpGet.path at /readyz.

So kube_pod_status_ready already 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.md gains 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 from commons/pkg/server rather than store-client and carries no client label. The row says it latches, points at kube_pod_container_status_restarts_total for the case the gauge cannot show, and recommends kube_pod_status_ready over it for the case it can.

  • commons/pkg/server/datastore_readiness.go gets 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 says Ready does not call LagState, so the next person to work on this does not assume the lag check is already wired.
  • Not in this PR: the name. connected reads as "currently attached" and the gauge means "started once", which no comment fully repairs. change_stream_watcher_started would put it in the family its siblings occupy, and started avoids colliding with the readiness probe this checker also serves. A rename is cheaper than it looks — the metric has no METRICS.md entry 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 new METRICS.md row records the mismatch so the question does not get lost.

    Type of Change


  • 🐛 Bug fix

  • ✨ New feature

  • 💥 Breaking change

  • 📚 Documentation

  • 🔧 Refactoring

  • 🔨 Build/CI
  • Component(s) Affected


  • Health Monitor

  • Core Service

  • Fault Management

  • Janitor

  • Deployment/Config

  • API/Interface

  • Preflight

  • Plugins

  • Documentation/CI

  • New Component

  • Multiple Components

  • Other
  • Testing


  • Tests pass locally

  • Manual testing completed

  • No breaking changes (or documented)
  • Tests pass locally — go test ./... -count=1 across commons exits 0: 21 packages ok, no failures, 5 with no test files. This module needs no envtest, so unlike most of this repository the suite covering the changed file actually ran here, commons/pkg/server included. gofmt, go build ./... and go 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 any LagState() call in that file, and SetWatcher(nil) returning early;

  • the three exit guards cited above, read in each component;

  • min_over_time(datastore_connected[30d]) == 1 on a live v1.29.0 install, across six pod lifetimes — two generations each of fault-quarantine, node-drainer and fault-remediation, so the window includes startups, with no gap in count_over_time;

  • that docs/METRICS.md has 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;

  • that WithReadinessCheck holds 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 # HELP line in /metrics output and nothing else.

    Checklist


  • Self-review completed

  • Documentation updated (if needed)

  • Ready for review
  • 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 main found 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_connected remains at 1 if the datastore is later lost; the component stops and the pod restarts.
    Specified which components expose the metric, noted that it has no client label, and recommended kube_pod_status_ready unless a component-specific signal is needed.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: KaivalyaMDabhadkar Review duration: 1788m
    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
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%