CASCL-1724: requeue DPA status write on conflict #55608
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 · 434 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.363
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #55608"
general
weight: 0.35
AlexanderYastrebov
<!-- dd-meta {"pullId":"00000000-0000-0000-0000-000000000000","source":"chat","resourceId":"bec0c19f-5cc4-4b0a-9eac-ff0d2eef1a7f","workflowId":"98db4137-81d8-438f-9601-eeb142d96cc2","codeChangeId":"98db4137-81d8-438f-9601-eeb142d96cc2","sourceType":"chat"} -->
What does this PR do?
Makes the Cluster Agent
DatadogPodAutoscaler(DPA) controller requeue the reconcile when a status write fails instead of silently dropping the update.updateAutoscalerStatusAndUpsertnow returns anautoscaling.ProcessResultand setsRequeuewhenupdatePodAutoscalerStatusreturns an error (e.g. an HTTP 409 conflict from a stale cachedresourceVersion). The two call sites propagate that result. The spec-write path already requeued on error, so no change was needed there.Motivation
CASCL-1724. A customer reported a DPA that stopped honoring its configured metric and continuously scaled down, with a 409 conflict logged on the leader every ~5 minutes.
Root cause: the status write reuses the
resourceVersionread from the informer cache (ObjectMeta: podAutoscaler.ObjectMeta); when that value is stale,UpdateStatusreturns 409. In the normal scaling path the resulting error was returned but the reconcile result stayedNoRequeue, so the key was forgotten and only retried on the next informer event (the ~5-minute resync explains the cadence).Fix approach (idiomatic controller pattern): on a status-write error, requeue and let the reconcile restart. The conflict is caused by a concurrent successful write to the object, which is itself delivered to the informer as a watch event, so a subsequent reconcile reads the up-to-date object from the cache and the write succeeds. Retries are bounded by the workqueue rate-limiter and
Process()'smaxRetry. This avoids adding live API reads inside the write path.Scope note validated during investigation: the 409 does not by itself cause the reported "CPU-only fallback". On a failed status write the controller still upserts the fresh recommendation into its internal store, and horizontal scaling runs before the status write, so the configured metric is still applied. The fallback is driven by main-recommendation staleness and is tracked separately; this PR fixes the conflict handling only.
Describe how you validated your changes
Added unit tests in
controller_test.godrivingupdateAutoscalerStatusAndUpsertagainst a fake dynamic client:TestUpdateAutoscalerStatusAndUpsertRequeuesOnConflict: a 409 on the status subresource makes the reconcile returnRequeueand surface the error, and the fresh recommendation is still persisted to the store.TestUpdateAutoscalerStatusAndUpsertNoConflict: a successful status write does not requeue (steady state preserved).Ran the full
pkg/clusteragent/autoscaling/workloadpackage test suite (go test -tags 'test kubeapiserver') — all green — andgofmt.Additional Notes
retry.RetryOnConflict+ live-read implementation on this branch, per review feedback.---
PR by Bits - View session in Datadog
Comment @datadog to request changes