Fix CAPI provider scale-down when current replicas exceed maxSize #10697
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 332 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.347
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #10697"
general
weight: 0.35
elmiko
What type of PR is this?
/kind bug
/area provider/cluster-api
What this PR does / why we need it:
With the Cluster API provider, lowering the
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-sizeannotation below a node group's current replica count deadlocks scale-down.DeleteNodesremoves nodes by callingSetSize(replicas - 1), butSetSizerejects any target abovemaxSize, even when that target is a decrease. With 4 replicas and max lowered to 2,SetSize(3)fails, so the group can never converge back into range:This PR enforces
maxSizeinSetSizeonly when the target is above the current replica count, which is when the call is actually increasing the size. Decreases toward or into the valid range are now allowed. TheminSizecheck is unchanged.This is the fix from #9396 by @MaxFedotov, carried over with its original authorship. That PR was closed by the triage bot after the migration notice told it to move to kubernetes-sigs/cluster-autoscaler. The ClusterAPI provider has since been moved back to this repo (#10150, kubernetes-sigs/cluster-autoscaler#61), so the fix belongs here again.
Which issue(s) this PR fixes:
Fixes #9395
Special notes for your reviewer:
TestSetSize/ScaleDownWhenAboveMax/{MachineSet,MachineDeployment}. On master without the fix these fail withsize increase too large - desired:3 max:2. With the fix,go test ./cloudprovider/clusterapi/passes.cluster-autoscaler-release-1.35,-1.36and-1.37. Once this merges, could it be cherry-picked to those branches so it ships in patch releases?Does this PR introduce a user-facing change?
``
release-noteCluster API provider: the autoscaler can now scale down a node group whose current replica count exceeds its max-size annotation, instead of failing with "size increase too large".
docs
``
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Bug Fixes
Scaling down a MachineSet or MachineDeployment that is already above its configured maximum is now allowed. Attempts to scale up beyond the maximum remain blocked.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->