refactor(backend): CSStateDump reads cluster and node pools from listers #7262
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
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.353
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #7262"
general
weight: 0.35
machi1990
What
The
CSStateDumpcontroller (backend/pkg/controllers/datadump/cs_state_dump.go) previously performed live Cosmos reads inSyncOnce:resourcesDBClient.HCPClusters(...).Get(...)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:clusterLister.Get(ctx, sub, rg, name)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
instantiateCsStateDumpControllerinregistration.go, sourced fromcontrollerContext.BackendInformers.Clusters()/.NodePools(). TheresourcesDBClientparameter is retained becauseNewClusterWatchingControllerstill 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-ClusterServiceIDskip and the"hcp_nodepool_name", nodePool.IDlog 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 to2:GetNodePoolloop into a singleListNodePoolscall filtered byid(search expressionid in (...)), and have CS embed the full node-pool version in the payload so the extra per-pool version-link resolution is avoided.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 afterwardsgo build ./...(backend) — passesgo 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/...— passesmake lint(backend) — 0 issuesdocs/cosmos-data-flow.mdupdated to describe the now-cached reads (the CS GETs are unchanged)