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 authored and ShyamsundarR committed Nov 12, 2024
1 parent 7a22e27 commit 1f11958
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion internal/controller/drplacementcontrol_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2309,7 +2309,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
14 changes: 9 additions & 5 deletions internal/controller/volumereplicationgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,12 +833,16 @@ func (v *VRGInstance) separatePVCsUsingOnlySC(storageClass *storagev1.StorageCla

replicationClassMatchFound := false

for _, replicationClass := range v.replClassList.Items {
if storageClass.Provisioner == replicationClass.Spec.Provisioner {
v.volRepPVCs = append(v.volRepPVCs, *pvc)
replicationClassMatchFound = true
pvcEnabledForVolSync := util.IsPVCMarkedForVolSync(v.instance.GetAnnotations())

break
if !pvcEnabledForVolSync {
for _, replicationClass := range v.replClassList.Items {
if storageClass.Provisioner == replicationClass.Spec.Provisioner {
v.volRepPVCs = append(v.volRepPVCs, *pvc)
replicationClassMatchFound = true

break
}
}
}

Expand Down

0 comments on commit 1f11958

Please sign in to comment.