Skip to content

Commit

Permalink
Rename annotation and other misc changes
Browse files Browse the repository at this point in the history
Signed-off-by: Benamar Mekhissi <[email protected]>
  • Loading branch information
Benamar Mekhissi committed Oct 28, 2024
1 parent 018f295 commit 74f8093
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
10 changes: 5 additions & 5 deletions internal/controller/drplacementcontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -1587,11 +1587,11 @@ func (d *DRPCInstance) generateVRG(dstCluster string, repState rmn.ReplicationSt
Name: d.instance.Name,
Namespace: d.vrgNamespace,
Annotations: map[string]string{
DestinationClusterAnnotationKey: dstCluster,
DoNotDeletePVCAnnotation: d.instance.GetAnnotations()[DoNotDeletePVCAnnotation],
DRPCUIDAnnotation: string(d.instance.UID),
rmnutil.IsCGEnabledAnnotation: d.instance.GetAnnotations()[rmnutil.IsCGEnabledAnnotation],
rmnutil.UseVolSyncForPVCProtection: d.instance.GetAnnotations()[rmnutil.UseVolSyncForPVCProtection],
DestinationClusterAnnotationKey: dstCluster,
DoNotDeletePVCAnnotation: d.instance.GetAnnotations()[DoNotDeletePVCAnnotation],
DRPCUIDAnnotation: string(d.instance.UID),
rmnutil.IsCGEnabledAnnotation: d.instance.GetAnnotations()[rmnutil.IsCGEnabledAnnotation],
rmnutil.UseVolSyncAnnotation: d.instance.GetAnnotations()[rmnutil.UseVolSyncAnnotation],
},
},
Spec: rmn.VolumeReplicationGroupSpec{
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/drplacementcontrol_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2872,7 +2872,7 @@ func constructVRGFromView(viewVRG *rmn.VolumeReplicationGroup) *rmn.VolumeReplic
fallthrough
case rmnutil.IsCGEnabledAnnotation:
fallthrough
case rmnutil.UseVolSyncForPVCProtection:
case rmnutil.UseVolSyncAnnotation:
fallthrough
case DRPCUIDAnnotation:
rmnutil.AddAnnotation(vrg, k, v)
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/util/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const (

IsCGEnabledAnnotation = "drplacementcontrol.ramendr.openshift.io/is-cg-enabled"

// Annotation
UseVolSyncForPVCProtection = "drplacementcontrol.ramendr.openshift.io/use-volsync-for-pvc-protection"
// When this annotation is set to true, VolSync will protect RBD PVCs.
UseVolSyncAnnotation = "drplacementcontrol.ramendr.openshift.io/use-volsync-for-pvc-protection"
)

type ResourceUpdater struct {
Expand Down Expand Up @@ -243,7 +243,7 @@ func IsCGEnabled(annotations map[string]string) bool {
}

func IsPVCMarkedForVolSync(annotations map[string]string) bool {
return annotations[UseVolSyncForPVCProtection] == "true"
return annotations[UseVolSyncAnnotation] == "true"
}

func TrimToK8sResourceNameLength(name string) string {
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/util/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ var _ = Describe("misc", func() {

Expect(util.IsPVCMarkedForVolSync(nil)).Should(Equal(false))
Expect(util.IsPVCMarkedForVolSync(map[string]string{})).Should(Equal(false))
Expect(util.IsPVCMarkedForVolSync(map[string]string{util.UseVolSyncForPVCProtection: "true"})).
Expect(util.IsPVCMarkedForVolSync(map[string]string{util.UseVolSyncAnnotation: "true"})).
Should(Equal(true))
})
3 changes: 1 addition & 2 deletions internal/controller/volsync/vshandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,14 +692,13 @@ var _ = Describe("VolSync_Handler", func() {
}, pvc)
}, maxWait, interval).Should(Succeed())

Expect(pvc.GetName()).To(Equal(rdSpec.ProtectedPVC.Name))
Expect(pvc.GetOwnerReferences()[0].Kind).To(Equal("ConfigMap"))
Expect(*pvc.Spec.VolumeMode).To(Equal(corev1.PersistentVolumeFilesystem))
Expect(k8sClient.Delete(ctx, pvc)).ToNot(HaveOccurred())
})

It("PrecreateDestPVCIfEnabled() should create PVC with volumeMode: Block", func() {
util.AddAnnotation(owner, util.UseVolSyncForPVCProtection, "true")
util.AddAnnotation(owner, util.UseVolSyncAnnotation, "true")
Expect(k8sClient.Update(ctx, owner)).To(Succeed())
rdSpecForBlockPVC := rdSpec.DeepCopy()
block := corev1.PersistentVolumeBlock
Expand Down

0 comments on commit 74f8093

Please sign in to comment.