Skip to content

Commit

Permalink
Enable DRPC Consistency Groups Using an Annotation
Browse files Browse the repository at this point in the history
Both annotations and the DRPC spec allow us to enable consistency groups (CG) on
a per-DRPC basis, providing more granular control compared to a global configuration.
However, we chose to use annotations instead of modifying the DRPC spec to prepare
for the future full use of CG. As CG usage matures, we will gradually phase out non-CG
snapshotting and replication. Using an annotation also makes it easier to remove for
backward compatibility.

Signed-off-by: Benamar Mekhissi <bmekhiss@ibm.com>
  • Loading branch information
Benamar Mekhissi authored and ShyamsundarR committed Jul 19, 2024
1 parent ba50c97 commit 210f00a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/controller/drplacementcontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,7 @@ func (d *DRPCInstance) generateVRG(dstCluster string, repState rmn.ReplicationSt
DestinationClusterAnnotationKey: dstCluster,
DoNotDeletePVCAnnotation: d.instance.GetAnnotations()[DoNotDeletePVCAnnotation],
DRPCUIDAnnotation: string(d.instance.UID),
rmnutil.IsCGEnabledAnnotation: d.instance.GetAnnotations()[rmnutil.IsCGEnabledAnnotation],
},
},
Spec: rmn.VolumeReplicationGroupSpec{
Expand Down
2 changes: 2 additions & 0 deletions internal/controller/drplacementcontrol_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2839,6 +2839,8 @@ func constructVRGFromView(viewVRG *rmn.VolumeReplicationGroup) *rmn.VolumeReplic
fallthrough
case DoNotDeletePVCAnnotation:
fallthrough
case rmnutil.IsCGEnabledAnnotation:
fallthrough
case DRPCUIDAnnotation:
rmnutil.AddAnnotation(vrg, k, v)
default:
Expand Down
10 changes: 10 additions & 0 deletions internal/controller/util/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
const (
OCMBackupLabelKey string = "cluster.open-cluster-management.io/backup"
OCMBackupLabelValue string = "ramen"

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

type ResourceUpdater struct {
Expand Down Expand Up @@ -212,3 +214,11 @@ func CreateNamespaceIfNotExists(ctx context.Context, k8sClient client.Client, na

return nil
}

func IsCGEnabled(annotations map[string]string) bool {
if annotations == nil {
return false
}

return annotations[IsCGEnabledAnnotation] == "true"
}
16 changes: 16 additions & 0 deletions internal/controller/util/misc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-FileCopyrightText: The RamenDR authors
// SPDX-License-Identifier: Apache-2.0

package util_test

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/ramendr/ramen/internal/controller/util"
)

var _ = Describe("misc", func() {
Expect(util.IsCGEnabled(nil)).Should(Equal(false))
Expect(util.IsCGEnabled(map[string]string{})).Should(Equal(false))
Expect(util.IsCGEnabled(map[string]string{util.IsCGEnabledAnnotation: "true"})).Should(Equal(true))
})

0 comments on commit 210f00a

Please sign in to comment.