From 7ffb662fda8bdc9bcc6d38dbf02b14557460c94d Mon Sep 17 00:00:00 2001 From: Luis Ramirez Date: Wed, 8 Nov 2023 11:39:09 -0600 Subject: [PATCH] Fix capacityType label in AWS ManagedNodeGroup Fixes an issue where the capacityType label inferred from an empty EKS ManagedNodeGroup does not match the same label on the node after it is created and joins the cluster --- cluster-autoscaler/cloudprovider/aws/aws_wrapper.go | 2 +- .../cloudprovider/aws/aws_wrapper_test.go | 6 +++--- .../cloudprovider/aws/managed_nodegroup_cache_test.go | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/aws/aws_wrapper.go b/cluster-autoscaler/cloudprovider/aws/aws_wrapper.go index 89ab6aefdb17..b8c1f71b661b 100644 --- a/cluster-autoscaler/cloudprovider/aws/aws_wrapper.go +++ b/cluster-autoscaler/cloudprovider/aws/aws_wrapper.go @@ -85,7 +85,7 @@ func (m *awsWrapper) getManagedNodegroupInfo(nodegroupName string, clusterName s } if r.Nodegroup.CapacityType != nil && len(*r.Nodegroup.CapacityType) > 0 { - labels["capacityType"] = *r.Nodegroup.CapacityType + labels["eks.amazonaws.com/capacityType"] = *r.Nodegroup.CapacityType } if r.Nodegroup.Version != nil && len(*r.Nodegroup.Version) > 0 { diff --git a/cluster-autoscaler/cloudprovider/aws/aws_wrapper_test.go b/cluster-autoscaler/cloudprovider/aws/aws_wrapper_test.go index b5c445434e71..63b5f23baea0 100644 --- a/cluster-autoscaler/cloudprovider/aws/aws_wrapper_test.go +++ b/cluster-autoscaler/cloudprovider/aws/aws_wrapper_test.go @@ -174,7 +174,7 @@ func TestGetManagedNodegroup(t *testing.T) { assert.Equal(t, labelMap[labelKey2], labelValue2) assert.Equal(t, labelMap["diskSize"], strconv.FormatInt(diskSize, 10)) assert.Equal(t, labelMap["amiType"], amiType) - assert.Equal(t, labelMap["capacityType"], capacityType) + assert.Equal(t, labelMap["eks.amazonaws.com/capacityType"], capacityType) assert.Equal(t, labelMap["k8sVersion"], k8sVersion) assert.Equal(t, labelMap["eks.amazonaws.com/nodegroup"], nodegroupName) assert.Equal(t, len(tagMap), 2) @@ -220,7 +220,7 @@ func TestGetManagedNodegroupWithNilValues(t *testing.T) { assert.Equal(t, len(taintList), 0) assert.Equal(t, len(labelMap), 4) assert.Equal(t, labelMap["amiType"], amiType) - assert.Equal(t, labelMap["capacityType"], capacityType) + assert.Equal(t, labelMap["eks.amazonaws.com/capacityType"], capacityType) assert.Equal(t, labelMap["k8sVersion"], k8sVersion) assert.Equal(t, labelMap["eks.amazonaws.com/nodegroup"], nodegroupName) assert.Equal(t, len(tagMap), 0) @@ -264,7 +264,7 @@ func TestGetManagedNodegroupWithEmptyValues(t *testing.T) { assert.Equal(t, len(taintList), 0) assert.Equal(t, len(labelMap), 4) assert.Equal(t, labelMap["amiType"], amiType) - assert.Equal(t, labelMap["capacityType"], capacityType) + assert.Equal(t, labelMap["eks.amazonaws.com/capacityType"], capacityType) assert.Equal(t, labelMap["k8sVersion"], k8sVersion) assert.Equal(t, labelMap["eks.amazonaws.com/nodegroup"], nodegroupName) assert.Equal(t, len(tagMap), 0) diff --git a/cluster-autoscaler/cloudprovider/aws/managed_nodegroup_cache_test.go b/cluster-autoscaler/cloudprovider/aws/managed_nodegroup_cache_test.go index 3024907d8a10..a944bf611ae2 100644 --- a/cluster-autoscaler/cloudprovider/aws/managed_nodegroup_cache_test.go +++ b/cluster-autoscaler/cloudprovider/aws/managed_nodegroup_cache_test.go @@ -133,7 +133,7 @@ func TestGetManagedNodegroupNoTaintsOrLabels(t *testing.T) { assert.Equal(t, len(cacheObj.taints), 0) assert.Equal(t, len(cacheObj.labels), 4) assert.Equal(t, cacheObj.labels["amiType"], amiType) - assert.Equal(t, cacheObj.labels["capacityType"], capacityType) + assert.Equal(t, cacheObj.labels["eks.amazonaws.com/capacityType"], capacityType) assert.Equal(t, cacheObj.labels["k8sVersion"], k8sVersion) assert.Equal(t, cacheObj.labels["eks.amazonaws.com/nodegroup"], nodegroupName) assert.Equal(t, len(cacheObj.tags), 0) @@ -213,7 +213,7 @@ func TestGetManagedNodegroupWithTaintsAndLabels(t *testing.T) { assert.Equal(t, cacheObj.labels[labelKey2], labelValue2) assert.Equal(t, cacheObj.labels["diskSize"], strconv.FormatInt(diskSize, 10)) assert.Equal(t, cacheObj.labels["amiType"], amiType) - assert.Equal(t, cacheObj.labels["capacityType"], capacityType) + assert.Equal(t, cacheObj.labels["eks.amazonaws.com/capacityType"], capacityType) assert.Equal(t, cacheObj.labels["k8sVersion"], k8sVersion) assert.Equal(t, cacheObj.labels["eks.amazonaws.com/nodegroup"], nodegroupName) assert.Equal(t, len(cacheObj.tags), 2) @@ -326,7 +326,7 @@ func TestGetManagedNodegroupInfoObjectNoCachedNodegroup(t *testing.T) { assert.Equal(t, mngInfoObject.labels[labelKey2], labelValue2) assert.Equal(t, mngInfoObject.labels["diskSize"], strconv.FormatInt(diskSize, 10)) assert.Equal(t, mngInfoObject.labels["amiType"], amiType) - assert.Equal(t, mngInfoObject.labels["capacityType"], capacityType) + assert.Equal(t, mngInfoObject.labels["eks.amazonaws.com/capacityType"], capacityType) assert.Equal(t, mngInfoObject.labels["k8sVersion"], k8sVersion) assert.Equal(t, mngInfoObject.labels["eks.amazonaws.com/nodegroup"], nodegroupName) assert.Equal(t, len(mngInfoObject.tags), 2) @@ -417,7 +417,7 @@ func TestGetManagedNodegroupLabelsNoCachedNodegroup(t *testing.T) { assert.Equal(t, labelsMap[labelKey2], labelValue2) assert.Equal(t, labelsMap["diskSize"], strconv.FormatInt(diskSize, 10)) assert.Equal(t, labelsMap["amiType"], amiType) - assert.Equal(t, labelsMap["capacityType"], capacityType) + assert.Equal(t, labelsMap["eks.amazonaws.com/capacityType"], capacityType) assert.Equal(t, labelsMap["k8sVersion"], k8sVersion) assert.Equal(t, labelsMap["eks.amazonaws.com/nodegroup"], nodegroupName) k.AssertCalled(t, "DescribeNodegroup", &eks.DescribeNodegroupInput{ @@ -513,7 +513,7 @@ func TestGetManagedNodegroupLabelsWithCachedNodegroupThatExpires(t *testing.T) { assert.Equal(t, newLabelsMap[labelKey2], labelValue2) assert.Equal(t, newLabelsMap["diskSize"], strconv.FormatInt(diskSize, 10)) assert.Equal(t, newLabelsMap["amiType"], amiType) - assert.Equal(t, newLabelsMap["capacityType"], capacityType) + assert.Equal(t, newLabelsMap["eks.amazonaws.com/capacityType"], capacityType) assert.Equal(t, newLabelsMap["k8sVersion"], k8sVersion) assert.Equal(t, newLabelsMap["eks.amazonaws.com/nodegroup"], nodegroupName) k.AssertCalled(t, "DescribeNodegroup", &eks.DescribeNodegroupInput{