diff --git a/cluster-autoscaler/core/utils/utils.go b/cluster-autoscaler/core/utils/utils.go index 6fd8354c23c4..eb4a3c40c406 100644 --- a/cluster-autoscaler/core/utils/utils.go +++ b/cluster-autoscaler/core/utils/utils.go @@ -99,8 +99,9 @@ func GetNodeInfosForGroups(nodes []*apiv1.Node, nodeInfoCache map[string]*schedu continue } - // No good template, check cache of previously running nodes. - if nodeInfoCache != nil { + // No good template, check cache of previously running nodes(only when nodeGrp min size is not zero. This is to avoid scenarios where nodeGrp instanceType is updated, + // but still cached old nodeTemplate is used) + if nodeInfoCache != nil && nodeGroup.MinSize() != 0 { if nodeInfo, found := nodeInfoCache[id]; found { if nodeInfoCopy, err := deepCopyNodeInfo(nodeInfo); err == nil { result[id] = nodeInfoCopy diff --git a/cluster-autoscaler/core/utils/utils_test.go b/cluster-autoscaler/core/utils/utils_test.go index f15234397dda..95bbe7b83eb9 100644 --- a/cluster-autoscaler/core/utils/utils_test.go +++ b/cluster-autoscaler/core/utils/utils_test.go @@ -210,7 +210,9 @@ func TestGetNodeInfosForGroupsCache(t *testing.T) { assertEqualNodeCapacities(t, ready2, info.Node()) info, found = res["ng4"] assert.True(t, found) - assertEqualNodeCapacities(t, ready6, info.Node()) + /* The below line is commented , as now the nodeTemplate is not formed from previously ready node of nodegrp + if nodeGrp has min size 0 */ + // assertEqualNodeCapacities(t, ready6, info.Node()) } func assertEqualNodeCapacities(t *testing.T, expected, actual *apiv1.Node) {