Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Drop stored version annotation 36 #1709

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/apis/v1/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const (
KubeletCompatibilityAnnotationKey = CompatibilityGroup + "/v1beta1-kubelet-conversion"
NodeClassReferenceAnnotationKey = CompatibilityGroup + "/v1beta1-nodeclass-reference"
NodeClaimTerminationTimestampAnnotationKey = Group + "/nodeclaim-termination-timestamp"
StoredVersionMigratedKey = Group + "/stored-version-migrated"
)

// Karpenter specific finalizers
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/v1/nodeclaim_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func (in *NodeClaim) ConvertTo(ctx context.Context, to apis.Convertible) error {
// Remove the annotations from the v1beta1 NodeClaim on the convert back
delete(v1beta1NC.Annotations, KubeletCompatibilityAnnotationKey)
delete(v1beta1NC.Annotations, NodeClassReferenceAnnotationKey)
// Drop the annotation so when roundtripping from v1, to v1beta1, and back to v1 the migration resource controller can re-annotate it
delete(v1beta1NC.Annotations, StoredVersionMigratedKey)
return nil
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/apis/v1/nodeclaim_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ var _ = Describe("Convert v1 to v1beta1 NodeClaim API", func() {
v1beta1nodeclaim.Annotations = nil
Expect(v1beta1nodeclaim.ObjectMeta).To(BeEquivalentTo(v1nodeclaim.ObjectMeta))
})
It("should drop v1 specific annotations on conversion", func() {
v1nodeclaim.ObjectMeta = test.ObjectMeta(
metav1.ObjectMeta{
Annotations: map[string]string{
StoredVersionMigratedKey: "true",
},
},
)
v1nc := v1nodeclaim.DeepCopy()
Expect(v1nodeclaim.ConvertTo(ctx, v1beta1nodeclaim)).To(Succeed())
Expect(v1nc.Annotations).To(HaveKey(StoredVersionMigratedKey))
Expect(v1beta1nodeclaim.Annotations).NotTo(HaveKey(StoredVersionMigratedKey))
})
Context("NodeClaim Spec", func() {
It("should convert v1 nodeclaim taints", func() {
v1nodeclaim.Spec.Taints = []v1.Taint{
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/v1/nodepool_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func (in *NodePool) ConvertTo(ctx context.Context, to apis.Convertible) error {
// Remove the annotations from the v1beta1 NodeClaim on the convert back
delete(v1beta1NP.Annotations, KubeletCompatibilityAnnotationKey)
delete(v1beta1NP.Annotations, NodeClassReferenceAnnotationKey)
// Drop the annotation so when roundtripping from v1, to v1beta1, and back to v1 the migration resource controller can re-annotate it
delete(v1beta1NP.Annotations, StoredVersionMigratedKey)
return nil
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/apis/v1/nodepool_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ var _ = Describe("Convert V1 to V1beta1 NodePool API", func() {
Expect(v1nodepool.ConvertTo(ctx, v1beta1nodepool)).To(Succeed())
Expect(v1beta1nodepool.ObjectMeta).To(BeEquivalentTo(v1nodepool.ObjectMeta))
})
It("should drop v1 specific annotations on conversion", func() {
v1nodepool.ObjectMeta = test.ObjectMeta(
metav1.ObjectMeta{
Annotations: map[string]string{
StoredVersionMigratedKey: "true",
},
},
)
v1np := v1nodepool.DeepCopy()
Expect(v1nodepool.ConvertTo(ctx, v1beta1nodepool)).To(Succeed())
Expect(v1np.Annotations).To(HaveKey(StoredVersionMigratedKey))
Expect(v1beta1nodepool.Annotations).NotTo(HaveKey(StoredVersionMigratedKey))
})
Context("NodePool Spec", func() {
It("should convert v1 nodepool weights", func() {
v1nodepool.Spec.Weight = lo.ToPtr(int32(62))
Expand Down
Loading