From 1a83553c3bcdbd4b6f9689b3e2bb60f074702757 Mon Sep 17 00:00:00 2001 From: Amanuel Engeda <74629455+engedaam@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:11:15 -0700 Subject: [PATCH] fix: Use NodeClaim annotations instead of NodeClass (#6654) --- pkg/cloudprovider/cloudprovider.go | 2 +- pkg/cloudprovider/suite_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/cloudprovider/cloudprovider.go b/pkg/cloudprovider/cloudprovider.go index 7968faffa844..3cec17461804 100644 --- a/pkg/cloudprovider/cloudprovider.go +++ b/pkg/cloudprovider/cloudprovider.go @@ -118,7 +118,7 @@ func (c *CloudProvider) Create(ctx context.Context, nodeClaim *karpv1.NodeClaim) return i.Name == instance.Type }) nc := c.instanceToNodeClaim(instance, instanceType, nodeClass) - nc.Annotations = lo.Assign(nodeClass.Annotations, map[string]string{ + nc.Annotations = lo.Assign(nc.Annotations, map[string]string{ v1.AnnotationKubeletCompatibilityHash: kubeletHash, v1.AnnotationEC2NodeClassHash: nodeClass.Hash(), v1.AnnotationEC2NodeClassHashVersion: v1.EC2NodeClassHashVersion, diff --git a/pkg/cloudprovider/suite_test.go b/pkg/cloudprovider/suite_test.go index 16d0a8298e9a..8056d2f23374 100644 --- a/pkg/cloudprovider/suite_test.go +++ b/pkg/cloudprovider/suite_test.go @@ -249,6 +249,14 @@ var _ = Describe("CloudProvider", func() { Expect(ok).To(BeTrue()) Expect(zoneID).To(Equal(subnet.ZoneID)) }) + It("should expect a strict set of annotation keys", func() { + ExpectApplied(ctx, env.Client, nodePool, nodeClass, nodeClaim) + cloudProviderNodeClaim, err := cloudProvider.Create(ctx, nodeClaim) + Expect(err).To(BeNil()) + Expect(cloudProviderNodeClaim).ToNot(BeNil()) + Expect(len(lo.Keys(cloudProviderNodeClaim.Annotations))).To(BeNumerically("==", 3)) + Expect(lo.Keys(cloudProviderNodeClaim.Annotations)).To(ContainElements(v1.AnnotationKubeletCompatibilityHash, v1.AnnotationEC2NodeClassHash, v1.AnnotationEC2NodeClassHashVersion)) + }) It("should return NodeClass Hash on the nodeClaim", func() { ExpectApplied(ctx, env.Client, nodePool, nodeClass, nodeClaim) cloudProviderNodeClaim, err := cloudProvider.Create(ctx, nodeClaim)