From 89a3bcc27e75a986f780bb57cf3cc6cb03fdb8f7 Mon Sep 17 00:00:00 2001 From: Reed Schalo Date: Fri, 15 Nov 2024 11:55:43 -0800 Subject: [PATCH 1/2] feat: add nodeclass tag validation during instance create --- pkg/cloudprovider/cloudprovider.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/cloudprovider/cloudprovider.go b/pkg/cloudprovider/cloudprovider.go index d03be9193d07..04b34fac97f1 100644 --- a/pkg/cloudprovider/cloudprovider.go +++ b/pkg/cloudprovider/cloudprovider.go @@ -18,6 +18,7 @@ import ( "context" stderrors "errors" "fmt" + "strings" "time" ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" @@ -240,7 +241,9 @@ func getTags(ctx context.Context, nodeClass *v1.EC2NodeClass, nodeClaim *karpv1. v1.EKSClusterNameTagKey: options.FromContext(ctx).ClusterName, v1.LabelNodeClass: nodeClass.Name, } - return lo.Assign(nodeClass.Spec.Tags, staticTags) + return lo.Assign(lo.OmitBy(nodeClass.Spec.Tags, func(key string, _ string) bool { + return strings.HasPrefix(key, "kubernetes.io/") + }), staticTags) } func (c *CloudProvider) resolveNodeClassFromNodeClaim(ctx context.Context, nodeClaim *karpv1.NodeClaim) (*v1.EC2NodeClass, error) { From bc5d5172ee001a1b7a881ba825b1351be7d5d905 Mon Sep 17 00:00:00 2001 From: Reed Schalo Date: Fri, 15 Nov 2024 12:00:55 -0800 Subject: [PATCH 2/2] scope down url --- pkg/cloudprovider/cloudprovider.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cloudprovider/cloudprovider.go b/pkg/cloudprovider/cloudprovider.go index 04b34fac97f1..9c02442ccbbd 100644 --- a/pkg/cloudprovider/cloudprovider.go +++ b/pkg/cloudprovider/cloudprovider.go @@ -242,7 +242,7 @@ func getTags(ctx context.Context, nodeClass *v1.EC2NodeClass, nodeClaim *karpv1. v1.LabelNodeClass: nodeClass.Name, } return lo.Assign(lo.OmitBy(nodeClass.Spec.Tags, func(key string, _ string) bool { - return strings.HasPrefix(key, "kubernetes.io/") + return strings.HasPrefix(key, "kubernetes.io/cluster/") }), staticTags) }