diff --git a/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_nodegroup.go b/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_nodegroup.go index ef1f2545b4ab..4fa942e2ab01 100644 --- a/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_nodegroup.go +++ b/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_nodegroup.go @@ -370,9 +370,9 @@ func newNodeGroupFromScalableResource(controller *machineController, unstructure return nil, err } - // We don't scale from 0 so nodes must belong to a nodegroup - // that has a scale size of at least 1. - if found && replicas == 0 { + // Ensure that if the nodegroup has 0 replicas it is capable + // of scaling before adding it. + if found && replicas == 0 && !scalableResource.CanScaleFromZero() { return nil, nil } diff --git a/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_nodegroup_test.go b/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_nodegroup_test.go index fcc2eee231a0..fcfb2b3ceea6 100644 --- a/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_nodegroup_test.go +++ b/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_nodegroup_test.go @@ -1210,7 +1210,7 @@ func TestNodeGroupTemplateNodeInfo(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { t.Run("MachineSet", func(t *testing.T) { - test(t, createMachineSetTestConfig(testNamespace, RandomString(6), 10, cloudprovider.JoinStringMaps(enableScaleAnnotations, tc.nodeGroupAnnotations)), + test(t, createMachineSetTestConfig(testNamespace, RandomString(6), RandomString(6), 10, cloudprovider.JoinStringMaps(enableScaleAnnotations, tc.nodeGroupAnnotations)), tc.config, ) }) @@ -1218,7 +1218,7 @@ func TestNodeGroupTemplateNodeInfo(t *testing.T) { t.Run("MachineDeployment", func(t *testing.T) { test( t, - createMachineDeploymentTestConfig(testNamespace, RandomString(6), 10, cloudprovider.JoinStringMaps(enableScaleAnnotations, tc.nodeGroupAnnotations)), + createMachineDeploymentTestConfig(testNamespace, RandomString(6), RandomString(6), 10, cloudprovider.JoinStringMaps(enableScaleAnnotations, tc.nodeGroupAnnotations)), tc.config, ) }) diff --git a/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_utils.go b/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_utils.go index 6a160401c4af..c4cbed381368 100644 --- a/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_utils.go +++ b/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_utils.go @@ -31,7 +31,7 @@ import ( const ( nodeGroupMinSizeAnnotationKey = "machine.openshift.io/cluster-api-autoscaler-node-group-min-size" nodeGroupMaxSizeAnnotationKey = "machine.openshift.io/cluster-api-autoscaler-node-group-max-size" - clusterNameLabel = "cluster.x-k8s.io/cluster-name" + clusterNameLabel = "machine.openshift.io/cluster-name" deprecatedClusterNameLabel = "cluster.k8s.io/cluster-name" cpuKey = "machine.openshift.io/vCPU"