fix(backend): strip volatile fields from Cluster Service errors in some calls #7711
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 441 lines diff across 5 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.364
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #7711"
general
weight: 0.35
miguelsorianod
Cluster Service API errors embed an OperationID and Timestamp that are unique to each individual request, even when the request is being rejected for the exact same reason on every retry (e.g. a cluster stuck in a non-updatable state). A controller's SyncOnce error becomes the Message of a Degraded condition on the resource's Controller document via ReportSyncError, and that condition is only rewritten to Cosmos when the Message actually changes. Because OperationID/Timestamp differ on every attempt, an otherwise-unchanged failure produced a different Message each sync, defeating that no-op check, triggering a Cosmos write, and re-triggering dependent controllers (including the one that just failed) in a continuous reconcile loop with no actual change in the underlying problem.
Add ocm.StripVolatileErrorFields, which rebuilds the Cluster Service error with Status/ID/HREF/Code/Reason/Details preserved but OperationID/Timestamp dropped, and call it at the 14 call sites across the cluster/nodepool/externalauth create, update, and delete controllers that wrap a Cluster Service client error into a Degraded condition message. This keeps the condition message stable across retries so a persistent, unchanged failure converges to a single Cosmos write instead of looping.
The downsides of stripping the error:
- ocm.StripVolatileErrorFields discards everything in the error chain except the OCM error itself. If a caller passes it an error that already has other context wrapped around the OCM error (instead of the raw OCM error directly), that other context is silently lost.
- We permanently lose the OCM error's Timestamp and OperationID, with no way to recover them later if they turn out to be needed (e.g. to correlate with a specific Cluster Service request in CS-side logs).
We lose some traceability but mitigates the unbounded Cosmos-write and reconcile loop, which we consider outweights losing that traceability.
<!-- Link to Jira issue -->
What
<!-- Briefly describe what this PR does -->
Why
<!-- Briefly explain why this change is needed -->
Testing
Testing is required for feature completion and tests should be part of the pull
request along with the feature changes.
Describe the testing provided. If you did not add tests, provide a clear
justification.
Special notes for your reviewer
<!-- optional -->
PR Checklist
If E2E tests are included:
demonstrate that the test is able to detect a defect/error and fail with
proper error message and logs which communicates nature of the problem.