Skip to content

Commit

Permalink
Update changelog, addl utils tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tesshu Flower <[email protected]>
  • Loading branch information
tesshuflower committed Jan 10, 2025
1 parent 76fd79e commit 2b9fd41
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- All movers should return error if not able to EnsurePVCFromSrc
- Fix for mover job/service name length too long (>63 chars) if the
replicationsource or replicationdestination CR name is too long

### Security

Expand Down
79 changes: 79 additions & 0 deletions controllers/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,4 +583,83 @@ var _ = Describe("utils tests", func() {
})

})

Describe("Name length limit tests", func() {
var ns *corev1.Namespace
var rd *volsyncv1alpha1.ReplicationDestination
var rdlongname *volsyncv1alpha1.ReplicationDestination

BeforeEach(func() {
ns = &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "utils-test-",
},
}

Expect(k8sClient.Create(ctx, ns)).To(Succeed())
Expect(ns.Name).NotTo(BeEmpty())
})

JustBeforeEach(func() {
// Create namespace for test
rd = &volsyncv1alpha1.ReplicationDestination{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "test-rd-owner-obj-",
Namespace: ns.Name,
},
Spec: volsyncv1alpha1.ReplicationDestinationSpec{},
}

rdlongname = &volsyncv1alpha1.ReplicationDestination{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "test-rd-owner-obj-aaa-bbb-ccc-this-name-is-greater-than-63chars-",
Namespace: ns.Name,
},
Spec: volsyncv1alpha1.ReplicationDestinationSpec{},
}

Expect(k8sClient.Create(ctx, rd)).To(Succeed())
Expect(k8sClient.Create(ctx, rdlongname)).To(Succeed())
})

AfterEach(func() {
Expect(k8sClient.Delete(ctx, ns)).To(Succeed())
})

Describe("Job name test", func() {
It("Should use the prefix + owner CR name when <= 63 chars", func() {
jobName := utils.GetJobName("myprefix-", rd)
Expect(jobName).To(Equal("myprefix-" + rd.GetName()))
})

It("Should use prefix + owner.UID when > 63 chars", func() {
jobName := utils.GetJobName("myprefix-", rdlongname)
Expect(jobName).To(Equal("myprefix-" + string(rdlongname.GetUID())))
})
})

Describe("Service name test", func() {
It("Should use the prefix + owner CR name when <= 63 chars", func() {
jobName := utils.GetServiceName("myprefix-", rd)
Expect(jobName).To(Equal("myprefix-" + rd.GetName()))
})

It("Should use prefix + owner.UID when > 63 chars", func() {
jobName := utils.GetServiceName("myprefix-", rdlongname)
Expect(jobName).To(Equal("myprefix-" + string(rdlongname.GetUID())))
})
})

Describe("Label value test", func() {
It("Should use the prefix + owner CR name when <= 63 chars", func() {
jobName := utils.GetOwnerNameLabelValue("myprefix-", rd)
Expect(jobName).To(Equal("myprefix-" + rd.GetName()))
})

It("Should use prefix + owner.UID when > 63 chars", func() {
jobName := utils.GetOwnerNameLabelValue("myprefix-", rdlongname)
Expect(jobName).To(Equal("myprefix-" + string(rdlongname.GetUID())))
})
})
})
})
2 changes: 2 additions & 0 deletions helm/volsync/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ annotations: # https://artifacthub.io/docs/topics/annotations/helm/
description: Updates the ensure_initialized function in the restic mover script to follow restic recommendations
- kind: fixed
description: All movers should return error if not able to EnsurePVCFromSrc
- kind: fixed
description: Fix for mover job/service name length too long (>63 chars) if the replicationsource or replicationdestination CR name is too long
- kind: security
description: kube-rbac-proxy upgraded to 0.18.1
artifacthub.io/crds: |
Expand Down

0 comments on commit 2b9fd41

Please sign in to comment.