Repository navigation
Description
Which component are you using?:
/area cluster-autoscaler
/kind bug
What version of the component are you using?:
Component version: cluster-autoscaler 1.32.0, clusterapi provider. The clusterapi provider code below is unchanged on master.
What k8s version are you using (kubectl version)?:
Workload cluster on Kubernetes 1.35.6, with a Kamaji control plane and KubeVirt workers. Cluster API v1.10.1.
What environment is this in?:
Cozystack, which runs tenant Kubernetes clusters through Cluster API and one cluster-autoscaler per tenant cluster, with --cloud-provider=clusterapi and --enforce-node-group-min-size=true.
What did you expect to happen?:
A MachineDeployment whose min-size annotation is above its current replicas grows to the min size, either for pending pods or through --enforce-node-group-min-size.
What happened instead?:
The group never grows. The scale-up for a pending pod asks for fewer nodes than the min size and is refused by the provider, even though it is an increase:
executor.go:166] Scale-up: setting group MachineDeployment/tenant-cplane/computeplane-cluster-md0 size to 1
clusterstate.go:313] Disabling scale-up for node group MachineDeployment/tenant-cplane/computeplane-cluster-md0 until 2026-10-06 18:53:42.863101496 +0000 UTC m=+326.766182875; errorClass=Other; errorCode=cloudProviderError
static_autoscaler.go:518] Failed to scale up: failed to increase node group size: size decrease too large - desired:1 min:2
orchestrator.go:328] ScaleUpToNodeGroupMinSize: node group is ready to scale up: &{[in backoff after failed scale-up]}
The refusal puts the group in backoff, and ScaleUpToNodeGroupMinSize skips a group in backoff. When the backoff expires, the pending-pod scale-up runs first again, asks for one node again, and is refused again. The group never leaves zero.
The refusal comes from SetSize, which rejects any nreplicas < r.minSize regardless of direction. IncreaseSize passes size + delta straight to it. The skip in backoff is in ScaleUpToNodeGroupMinSize.
How to reproduce it (as minimally and precisely as possible):
- Create a MachineDeployment with
cluster-api-autoscaler-node-group-min-size: "0"and max size 2, at 0 replicas. - Raise both annotations to "2". Cluster API keeps the live
spec.replicas: 0on that update, because the object already carries replicas. - Leave a pod pending that one node of the group would fit.
The autoscaler logs the lines above every backoff period, and the MachineDeployment stays at 0.
Anything else we need to know?:
This is the bug in #4942, which the triage bot closed as stale. The code is still there.
Refusing only a decrease below the min size fixes it: fetch the scale first, and return the error when nreplicas < r.minSize && nreplicas < current replicas. DecreaseTargetSize keeps its guard that way, and DeleteNodes already checks the min size itself. I have the change with tests for both directions and can send it as a PR.
I hit this in Cozystack, a CNCF project I maintain. The fix ships there as a patch on its autoscaler image, and the patch goes away once this is fixed here.
Activity
fix(kubernetes, e2e): unblock autoscaling below min size, size the co…
Siddhartha-singh01 commentedon Oct 17, 2026
I checked this against current
kubernetes/autoscalermaster andkubernetes-sigs/cluster-autoscalermain. The loop in the report is still in the code, and the issue is unassigned.IncreaseSizeforwardsreplicas + deltastraight toSetSize:SetSizerejects any target belowminSize, including an increase:A pending pod that needs one node, on a MachineDeployment at 0 with min 2, calls
IncreaseSize(1).SetSize(1)returns that error. The core records it as a cloud-provider error and puts the group in backoff.ScaleUpToNodeGroupMinSizewould ask forminSize - targetSizenodes, whichSetSizewould accept, butIsNodeGroupReadyToScaleUpreturns the backoff reason and the group is skipped. When the backoff expires, the pending-pod scale-up runs first and fails the same way, so the group stays at 0.Proposed fix, only in
(*nodegroup).IncreaseSize: ifsize+deltais still belowMinSize(), raise the target toMinSize()before callingSetSize. A request to grow stays a grow, and the first successful scale-up lands on the minimum instead of being rejected.SetSizeshould keep rejecting targets below min, so scale-down cannot pass it.DecreaseTargetSizestays as it is.Test in
clusterapi_nodegroup_test.go:IncreaseSize(1)patchesspec.replicasto 2 and returns nilIncreaseSize(1)still targets 3SetSizePlease take a look at this approach.
/assign
/cc @enxebre @elmiko @jackfrancis
elmiko commentedon Oct 20, 2026
thanks for reporting this, i'm surprised that the group does not increase to its minimum size.
elmiko commentedon Oct 20, 2026
fwiw, i think we should not be increasing the replicas to something lower than the minimum when
--enforce-node-group-min-sizeis set. if we see anIncreaseSizerequest happen, and the flag is set, we should increase the replicas to the minimum. i think.elmiko commentedon Oct 20, 2026
/triage accepted