Skip to content

Commit

Permalink
Don't delete PVC when reconciling VRs as secondary
Browse files Browse the repository at this point in the history
The PVC is owned by OCM and will be removed by OCM. The same reason used
in RamenDR#1007, but we don't know about any issue caused by this attempt.

Fixes: RamenDR#1022
Updates: 165fec2
Signed-off-by: Nir Soffer <[email protected]>
(cherry picked from commit fbc629a)
  • Loading branch information
nirs authored and ShyamsundarR committed Aug 30, 2023
1 parent d09475e commit d0bdb2d
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions controllers/vrg_volrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,7 @@ func (v *VRGInstance) reconcileVRAsSecondary(pvc *corev1.PersistentVolumeClaim,
skip bool = true
)

if pvc.GetAnnotations() != nil && pvc.GetAnnotations()[RestoreAnnotation] == RestoredByRamen {
// We created the PVC, delete it
if deleted := v.deletePVCIfNotInUse(pvc, log); !deleted {
return requeue, false, skip
}
} else if !v.isPVCReadyForSecondary(pvc, log) {
if !v.isPVCReadyForSecondary(pvc, log) {
return requeue, false, skip
}

Expand Down Expand Up @@ -177,14 +172,6 @@ func (v *VRGInstance) isPVCReadyForSecondary(pvc *corev1.PersistentVolumeClaim,
return !v.isPVCInUse(pvc, log, "Secondary transition")
}

func (v *VRGInstance) deletePVCIfNotInUse(pvc *corev1.PersistentVolumeClaim, log logr.Logger) bool {
if v.isPVCInUse(pvc, log, "PVC deletion") {
return false
}

return rmnutil.DeletePVC(v.ctx, v.reconciler.Client, pvc.Name, pvc.Namespace, log) == nil
}

func (v *VRGInstance) isPVCInUse(pvc *corev1.PersistentVolumeClaim, log logr.Logger, operation string) bool {
const inUse bool = true
// Check if any pod definitions exist referencing the PVC
Expand Down

0 comments on commit d0bdb2d

Please sign in to comment.