8000 Ensure PVC is deselected only when not in both VR and VS lists by ShyamsundarR · Pull Request #2121 · RamenDR/ramen · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Ensure PVC is deselected only when not in both VR and VS lists #2121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions internal/controller/volumereplicationgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1506,11 +1506,16 @@ func (v *VRGInstance) pvcsDeselectedUnprotect() error {
pvcNamespacedName := client.ObjectKeyFromObject(&pvc)
log1 := log.WithValues("pvc", pvcNamespacedName.String())

if _, ok := pvcsVr[pvcNamespacedName]; !ok {
v.pvcUnprotectVolRep(pvc, log1.WithName("VolRep"))
_, pvcUnderVRProtection := pvcsVr[pvcNamespacedName]
_, pvcUnderVSProtection := pvcsVs[pvcNamespacedName]

if pvcUnderVRProtection || pvcUnderVSProtection {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the PVC is deleted, but the label is still there, it will still be in both lists (pvcsOwned and either pvcsVr or pvcsVr). That means we will not unprotect the deleted PVC as the condition will evaluate to true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted PVCs go through the un-protection flow from reconcileVolRepsAsPrimary and pvcUnprotectVolSyncIfDeleted, so you are correct that in this code path they will be in one of the lists and get processed later for deletion. This (pvcsDeselectedUnprotect) function is only for deselected PVCs.

continue
}

if _, ok := pvcsVs[pvcNamespacedName]; !ok {
if controllerutil.ContainsFinalizer(&pvc, PvcVRFinalizerProtected) {
v.pvcUnprotectVolRep(pvc, log1.WithName("VolRep"))
} else {
v.pvcUnprotectVolSync(pvc, log1.WithName("VolSync"))
}
}
Expand Down
9 changes: 2 additions & 7 deletions internal/controller/vrg_volrep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,7 @@ func (v *vrgTest) cleanupPVCs(
} else if vrg.Spec.ReplicationState == ramendrv1alpha1.Primary {
pvcPostDeleteVerify1 = func(pvcNamespacedName types.NamespacedName, pvName string) {
pvcPostDeleteVerify(pvcNamespacedName, pvName)
pvcUnprotectedEventuallyVerify(client.ObjectKeyFromObject(vrg), pvcNamespacedName, pvName)
pvcUnprotectedVerify(*vrg, pvcNamespacedName, pvName)
}
}

Expand Down Expand Up @@ -2610,11 +2610,6 @@ func pvcDelete(
postDeleteVerify(pvcNamespacedName, pvNamespacedName.Name)
}

func pvcUnprotectedEventuallyVerify(vrgNamespacedName, pvcNamespacedName types.NamespacedName, pvName string) {
pvAndPvcObjectReplicasAbsentVerify(vrgNamespacedName, pvcNamespacedName, pvName)
vrgPvcStatusAbsentEventually(vrgNamespacedName, pvcNamespacedName)
}

func vrgPvcStatusAbsentEventually(vrgNamespacedName, pvcNamespacedName types.NamespacedName) {
Eventually(func() *ramendrv1alpha1.ProtectedPVC {
return vrgController.FindProtectedPVC(vrgGet(vrgNamespacedName), pvcNamespacedName.Namespace, pvcNamespacedName.Name)
Expand All @@ -2624,8 +2619,8 @@ func vrgPvcStatusAbsentEventually(vrgNamespacedName, pvcNamespacedName types.Nam
func pvcUnprotectedVerify(
vrg ramendrv1alpha1.VolumeReplicationGroup, pvcNamespacedName types.NamespacedName, pvName string,
) {
vrgPvcStatusAbsentEventually(client.ObjectKeyFromObject(&vrg), pvcNamespacedName)
pvAndPvcObjectReplicasAbsentVerify(client.ObjectKeyFromObject(&vrg), pvcNamespacedName, pvName)
vrgPvcStatusAbsentVerify(vrg, pvcNamespacedName, pvName)
}

type pvcPreDeleteVerify func(ramendrv1alpha1.VolumeReplicationGroup, types.NamespacedName, string)
Expand Down
0