Skip to content

Commit

Permalink
update for PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rschalo committed Jun 17, 2024
1 parent 79c97ea commit 4011716
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/v1beta1/ec2nodeclass_validation_cel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var _ = Describe("CEL/Validation", func() {
}
Expect(env.Client.Create(ctx, nc)).To(Not(Succeed()))
nc.Spec.Tags = map[string]string{
v1beta1.EksClusterNameAnnotationKey: "test",
v1beta1.EKSClusterNameAnnotationKey: "test",
}
Expect(env.Client.Create(ctx, nc)).To(Not(Succeed()))
nc.Spec.Tags = map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/v1beta1/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var (
// https://docs.aws.amazon.com/eks/latest/APIReference/API_CreateCluster.html
regexp.MustCompile(`^kubernetes\.io/cluster/[0-9A-Za-z][A-Za-z0-9\-_]*$`),
regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(v1beta1.NodePoolLabelKey))),
regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(EksClusterNameAnnotationKey))),
regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(EKSClusterNameAnnotationKey))),
regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(LabelNodeClass))),
regexp.MustCompile(fmt.Sprintf("^%s$", regexp.QuoteMeta(TagNodeClaim))),
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloudprovider/cloudprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ func (c *CloudProvider) instanceToNodeClaim(i *instance.Instance, instanceType *
if v, ok := i.Tags[corev1beta1.NodePoolLabelKey]; ok {
labels[corev1beta1.NodePoolLabelKey] = v
}
if v, ok := i.Tags[v1beta1.EksClusterNameAnnotationKey]; ok {
annotations[v1beta1.EksClusterNameAnnotationKey] = v
if v, ok := i.Tags[v1beta1.EKSClusterNameAnnotationKey]; ok {
annotations[v1beta1.EKSClusterNameAnnotationKey] = v
}
nodeClaim.Labels = labels
nodeClaim.Annotations = annotations
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/nodeclaim/garbagecollection/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *Controller) Reconcile(ctx context.Context) (reconcile.Result, error) {
return reconcile.Result{}, fmt.Errorf("listing cloudprovider machines, %w", err)
}
managedRetrieved := lo.Filter(retrieved, func(nc *corev1beta1.NodeClaim, _ int) bool {
return nc.Annotations[v1beta1.EksClusterNameAnnotationKey] != "" && nc.DeletionTimestamp.IsZero()
return nc.Annotations[v1beta1.EKSClusterNameAnnotationKey] != "" && nc.DeletionTimestamp.IsZero()
})
nodeClaimList := &corev1beta1.NodeClaimList{}
if err = c.kubeClient.List(ctx, nodeClaimList); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/controllers/nodeclaim/garbagecollection/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ var _ = Describe("GarbageCollection", func() {
Value: aws.String(nodeClass.Name),
},
{
Key: aws.String(v1beta1.EksClusterNameAnnotationKey),
Key: aws.String(v1beta1.EKSClusterNameAnnotationKey),
Value: aws.String(options.FromContext(ctx).ClusterName),
},
},
Expand Down Expand Up @@ -181,7 +181,7 @@ var _ = Describe("GarbageCollection", func() {
Value: aws.String("default"),
},
{
Key: aws.String(v1beta1.EksClusterNameAnnotationKey),
Key: aws.String(v1beta1.EKSClusterNameAnnotationKey),
Value: aws.String(options.FromContext(ctx).ClusterName),
},
},
Expand Down Expand Up @@ -286,7 +286,7 @@ var _ = Describe("GarbageCollection", func() {
It("should not delete an instance if it was not launched by a NodeClaim", func() {
// Remove the "eks:eks-cluster-name" tag (this isn't launched by a machine)
instance.Tags = lo.Reject(instance.Tags, func(t *ec2.Tag, _ int) bool {
return aws.StringValue(t.Key) == v1beta1.EksClusterNameAnnotationKey
return aws.StringValue(t.Key) == v1beta1.EKSClusterNameAnnotationKey
})

// Launch time was 1m ago
Expand Down Expand Up @@ -344,7 +344,7 @@ var _ = Describe("GarbageCollection", func() {
Value: aws.String("default"),
},
{
Key: aws.String(v1beta1.EksClusterNameAnnotationKey),
Key: aws.String(v1beta1.EKSClusterNameAnnotationKey),
Value: aws.String(options.FromContext(ctx).ClusterName),
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/nodeclaim/tagging/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var _ = Describe("TaggingController", func() {
Value: aws.String("default"),
},
{
Key: aws.String(v1beta1.EksClusterNameAnnotationKey),
Key: aws.String(v1beta1.EKSClusterNameAnnotationKey),
Value: aws.String(options.FromContext(ctx).ClusterName),
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func getTags(ctx context.Context, nodeClass *v1beta1.EC2NodeClass, nodeClaim *co
staticTags := map[string]string{
fmt.Sprintf("kubernetes.io/cluster/%s", options.FromContext(ctx).ClusterName): "owned",
corev1beta1.NodePoolLabelKey: nodeClaim.Labels[corev1beta1.NodePoolLabelKey],
v1beta1.EksClusterNameAnnotationKey: options.FromContext(ctx).ClusterName,
v1beta1.EKSClusterNameAnnotationKey: options.FromContext(ctx).ClusterName,
v1beta1.LabelNodeClass: nodeClass.Name,
}
return lo.Assign(nodeClass.Spec.Tags, staticTags)
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/instance/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ var _ = Describe("InstanceProvider", func() {
Value: aws.String("default"),
},
{
Key: aws.String(v1beta1.EksClusterNameAnnotationKey),
Key: aws.String(v1beta1.EKSClusterNameAnnotationKey),
Value: aws.String(options.FromContext(ctx).ClusterName),
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/launchtemplate/launchtemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func (p *DefaultProvider) createLaunchTemplate(ctx context.Context, options *ami
{
ResourceType: aws.String(ec2.ResourceTypeLaunchTemplate),
Tags: utils.MergeTags(options.Tags, map[string]string{
v1beta1.EksClusterNameAnnotationKey: options.ClusterName,
v1beta1.EKSClusterNameAnnotationKey: options.ClusterName,
v1beta1.TagManagedLaunchTemplate: options.ClusterName,
v1beta1.LabelNodeClass: options.NodeClassName,
}),
Expand Down
2 changes: 1 addition & 1 deletion test/suites/integration/tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ var _ = Describe("Tags", func() {

nodeInstance := instance.NewInstance(lo.ToPtr(env.GetInstance(node.Name)))
Expect(nodeInstance.Tags).To(HaveKeyWithValue("Name", node.Name))
Expect(nodeInstance.Tags).To(HaveKeyWithValue(v1beta1.EksClusterNameAnnotationKey, node.Name))
Expect(nodeInstance.Tags).To(HaveKeyWithValue(v1beta1.EKSClusterNameAnnotationKey, node.Name))
Expect(nodeInstance.Tags).To(HaveKey("karpenter.sh/nodeclaim"))
})

Expand Down
2 changes: 1 addition & 1 deletion test/suites/integration/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ var _ = Describe("Validation", func() {
nodeClass.Spec.Tags = map[string]string{"karpenter.sh/nodepool": "custom-value"}
Expect(env.Client.Create(env.Context, nodeClass)).ToNot(Succeed())

nodeClass.Spec.Tags = map[string]string{"eks:eks-cluster-name": env.ClusterName}
nodeClass.Spec.Tags = map[string]string{v1beta1.EKSClusterNameAnnotationKey: env.ClusterName}
Expect(env.Client.Create(env.Context, nodeClass)).ToNot(Succeed())

nodeClass.Spec.Tags = map[string]string{fmt.Sprintf("kubernetes.io/cluster/%s", env.ClusterName): "owned"}
Expand Down
2 changes: 1 addition & 1 deletion test/suites/nodeclaim/garbage_collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ var _ = Describe("GarbageCollection", func() {
Resources: []*string{out.Instances[0].InstanceId},
Tags: []*ec2.Tag{
{
Key: aws.String(v1beta1.EksClusterNameAnnotationKey),
Key: aws.String(v1beta1.EKSClusterNameAnnotationKey),
Value: aws.String(env.ClusterName),
},
},
Expand Down

0 comments on commit 4011716

Please sign in to comment.