Skip to content

Commit

Permalink
Filter out the do-no-delete annotation
Browse files Browse the repository at this point in the history
This annotation is added to the application PVC on the source relocate.
At the time the annotation is added the protectedPVCs were already
propagated to the target clusters, so it is never propagated to the
target clusters. However if the annotation will be propagated to the
target clusters it can break things, so now we filter it out when
copying the PVC annotation to the protected PVC.

Signed-off-by: Nir Soffer <[email protected]>
(cherry picked from commit 825a0de)
  • Loading branch information
nirs authored and raghavendra-talur committed Sep 11, 2023
1 parent 2f296bc commit 511aa72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions controllers/vrg_volsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"

ramendrv1alpha1 "github.com/ramendr/ramen/api/v1alpha1"
"github.com/ramendr/ramen/controllers/volsync"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -373,12 +374,15 @@ func (v VRGInstance) isVolSyncProtectedPVCConditionReady(conType string) bool {
// protectedPVCAnnotations return the annotations that we must propagate to the
// destination cluster:
// - apps.open-cluster-management.io/* - required to make the protected PVC
// owned by OCM when DR is disabled.
// owned by OCM when DR is disabled. Copy all annnotations except the
// special "do-not-delete" annotation, used only on the source cluster
// during relocate.
func protectedPVCAnnotations(pvc corev1.PersistentVolumeClaim) map[string]string {
res := map[string]string{}

for key, value := range pvc.Annotations {
if strings.HasPrefix(key, "apps.open-cluster-management.io/") {
if strings.HasPrefix(key, "apps.open-cluster-management.io/") &&
key != volsync.ACMAppSubDoNotDeleteAnnotation {
res[key] = value
}
}
Expand Down
4 changes: 4 additions & 0 deletions controllers/vrg_volsync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ var _ = Describe("VolumeReplicationGroupVolSyncController", func() {
pvcAnnotations := map[string]string{
"apps.open-cluster-management.io/hosting-subscription": "sub-name",
"apps.open-cluster-management.io/reconcile-option": "merge",
volsync.ACMAppSubDoNotDeleteAnnotation: volsync.ACMAppSubDoNotDeleteAnnotationVal,
"pv.kubernetes.io/bind-completed": "yes",
"volume.kubernetes.io/storage-provisioner": "provisioner",
}
Expand Down Expand Up @@ -165,6 +166,9 @@ var _ = Describe("VolumeReplicationGroupVolSyncController", func() {
Expect(vsPvc.Annotations).To(HaveKeyWithValue(
"apps.open-cluster-management.io/reconcile-option", "merge"))

// Except the do-no-delete annotion
Expect(vsPvc.Annotations).NotTo(HaveKey(volsync.ACMAppSubDoNotDeleteAnnotation))

// Other annotations are droopped.
Expect(vsPvc.Annotations).NotTo(HaveKey("pv.kubernetes.io/bind-completed"))
Expect(vsPvc.Annotations).NotTo(HaveKey("volume.kubernetes.io/storage-provisioner"))
Expand Down

0 comments on commit 511aa72

Please sign in to comment.