From d0bdb2db4e90474c3a6b1f3f9a986ad29b4d1c72 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Mon, 7 Aug 2023 02:18:04 +0300 Subject: [PATCH] Don't delete PVC when reconciling VRs as secondary The PVC is owned by OCM and will be removed by OCM. The same reason used in #1007, but we don't know about any issue caused by this attempt. Fixes: #1022 Updates: 165fec276514 Signed-off-by: Nir Soffer (cherry picked from commit fbc629a8764cae5a0f52e284cb53b6c2298b63be) --- controllers/vrg_volrep.go | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/controllers/vrg_volrep.go b/controllers/vrg_volrep.go index 2472ce3ea..622e78c49 100644 --- a/controllers/vrg_volrep.go +++ b/controllers/vrg_volrep.go @@ -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 } @@ -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