← Back to Pull requests

refactor(backend): CSStateDump reads cluster and node pools from listers #7262

Closed
unknown closed this pull request without merging on Sep 30, 2026 15:37 UTC
View on GitHub
unknown unknown commented on Sep 30, 2026 07:06 UTC
Author

What

The CSStateDump controller (backend/pkg/controllers/datadump/cs_state_dump.go) previously performed live Cosmos reads in SyncOnce:

  • the cluster via resourcesDBClient.HCPClusters(...).Get(...)

  • the node pools via resourcesDBClient.HCPClusters(...).NodePools(...).List(...)
  • This changes both reads to use the informer-backed listers instead, matching the pattern already used by control_plane_desired_version_controller:

  • cluster: clusterLister.Get(ctx, sub, rg, name)

  • node pools: nodePoolLister.ListForCluster(ctx, sub, rg, name) (returns a plain []coreapi.NodePool, so the previous iterator .Items(ctx) / .GetError() handling is removed)
  • The listers are supplied to the controller through instantiateCsStateDumpController in registration.go, sourced from controllerContext.BackendInformers.Clusters() / .NodePools(). The resourcesDBClient parameter is retained because NewClusterWatchingController still needs it.

    Why

    This controller is a periodic, best-effort state-dumper. Reading the cluster and its node pools from the shared informer cache (which is already Cosmos-backed) avoids redundant live Cosmos round-trips on every sync, reducing load on the database for data the backend already has cached.

    Scope

    This PR only changes the source of the cluster + node-pool reads (Cosmos → lister). The per-node-pool csClient.GetNodePool(...) loop against Cluster Service is intentionally left byte-for-byte unchanged, including the missing-ClusterServiceID skip and the "hcp_nodepool_name", nodePool.ID log field.

    Follow-up (second improvement — separate PR)

    This is the first of two improvements to this controller. The second, outlined in the discussion on https://github.com/Azure/ARO-HCP/pull/7258#issuecomment-5908955178, reduces the number of Cluster Service GET calls per eligible sync from 2 (1 + N) down to 2:

  • Node pools: collapse the per-node-pool GetNodePool loop into a single ListNodePools call filtered by id (search expression id in (...)), and have CS embed the full node-pool version in the payload so the extra per-pool version-link resolution is avoided.

  • Cluster: have CS embed the full autoscaler in the GET cluster response so the autoscaler-link resolution round-trip is avoided — tracked by https://redhat.atlassian.net/browse/ARO-28376.
  • That work depends on the CS-side changes and will land as its own PR; it is intentionally out of scope here.

    Tests / validation

  • make mocks fmt — clean working tree afterwards

  • go build ./... (backend) — passes

  • go test ./pkg/controllers/datadump/... — passes (tests adapted to populate the new listers via DB-backed test listers over the same fake Cosmos client; assertions unchanged)

  • go test ./pkg/app/... — passes

  • make lint (backend) — 0 issues

  • docs/cosmos-data-flow.md updated to describe the now-cached reads (the CS GETs are unchanged)
  • Diff: 367 lines (+275 / -92) across 4 files Reviewer: machi1990 Review duration: 510m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 367 lines diff across 4 files
    0.43
    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.353
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #7262"
    general weight: 0.35
    Reviewers
    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: 42.7% (MEDIUM) · Higher = larger blast radius
    42.7%
    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: 16.9% · Safe to merge
    16.9%
    Repository