From 8eb4f0f45a21f038f7977047fbf72dce43a75731 Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Sun, 28 Jan 2024 16:23:15 -0800 Subject: [PATCH] chore: Scope list call with EC2NodeClass tag (#5545) --- pkg/controllers/nodeclaim/garbagecollection/suite_test.go | 8 ++++++++ pkg/providers/instance/instance.go | 4 ++++ pkg/providers/instance/suite_test.go | 4 ++++ test/suites/nodeclaim/garbage_collection_test.go | 5 +++++ 4 files changed, 21 insertions(+) diff --git a/pkg/controllers/nodeclaim/garbagecollection/suite_test.go b/pkg/controllers/nodeclaim/garbagecollection/suite_test.go index 71ecc6f9faee..6527c20a2a4a 100644 --- a/pkg/controllers/nodeclaim/garbagecollection/suite_test.go +++ b/pkg/controllers/nodeclaim/garbagecollection/suite_test.go @@ -111,6 +111,10 @@ var _ = Describe("GarbageCollection", func() { Key: aws.String(corev1beta1.NodePoolLabelKey), Value: aws.String(nodePool.Name), }, + { + Key: aws.String(v1beta1.LabelNodeClass), + Value: aws.String(nodeClass.Name), + }, { Key: aws.String(corev1beta1.ManagedByAnnotationKey), Value: aws.String(options.FromContext(ctx).ClusterName), @@ -175,6 +179,10 @@ var _ = Describe("GarbageCollection", func() { Key: aws.String(corev1beta1.NodePoolLabelKey), Value: aws.String("default"), }, + { + Key: aws.String(v1beta1.LabelNodeClass), + Value: aws.String("default"), + }, { Key: aws.String(corev1beta1.ManagedByAnnotationKey), Value: aws.String(options.FromContext(ctx).ClusterName), diff --git a/pkg/providers/instance/instance.go b/pkg/providers/instance/instance.go index 7d393356da9d..5d44e19503d0 100644 --- a/pkg/providers/instance/instance.go +++ b/pkg/providers/instance/instance.go @@ -132,6 +132,10 @@ func (p *Provider) List(ctx context.Context) ([]*Instance, error) { Name: aws.String("tag-key"), Values: aws.StringSlice([]string{corev1beta1.NodePoolLabelKey}), }, + { + Name: aws.String("tag-key"), + Values: aws.StringSlice([]string{v1beta1.LabelNodeClass}), + }, { Name: aws.String("tag-key"), Values: aws.StringSlice([]string{fmt.Sprintf("kubernetes.io/cluster/%s", options.FromContext(ctx).ClusterName)}), diff --git a/pkg/providers/instance/suite_test.go b/pkg/providers/instance/suite_test.go index 73d9212b6cae..e1aa36692b7e 100644 --- a/pkg/providers/instance/suite_test.go +++ b/pkg/providers/instance/suite_test.go @@ -146,6 +146,10 @@ var _ = Describe("InstanceProvider", func() { Key: aws.String(corev1beta1.NodePoolLabelKey), Value: aws.String("default"), }, + { + Key: aws.String(v1beta1.LabelNodeClass), + Value: aws.String("default"), + }, { Key: aws.String(corev1beta1.ManagedByAnnotationKey), Value: aws.String(options.FromContext(ctx).ClusterName), diff --git a/test/suites/nodeclaim/garbage_collection_test.go b/test/suites/nodeclaim/garbage_collection_test.go index 7317c93c88e1..35d5dd4700bc 100644 --- a/test/suites/nodeclaim/garbage_collection_test.go +++ b/test/suites/nodeclaim/garbage_collection_test.go @@ -28,6 +28,7 @@ import ( corev1beta1 "sigs.k8s.io/karpenter/pkg/apis/v1beta1" coretest "sigs.k8s.io/karpenter/pkg/test" + "github.com/aws/karpenter-provider-aws/pkg/apis/v1beta1" awserrors "github.com/aws/karpenter-provider-aws/pkg/errors" "github.com/aws/karpenter-provider-aws/pkg/utils" environmentaws "github.com/aws/karpenter-provider-aws/test/pkg/environment/aws" @@ -84,6 +85,10 @@ var _ = Describe("GarbageCollection", func() { Key: aws.String(corev1beta1.NodePoolLabelKey), Value: aws.String(nodePool.Name), }, + { + Key: aws.String(v1beta1.LabelNodeClass), + Value: aws.String(nodeClass.Name), + }, }, }, },