From 76198b2bd062a40d8d0b5f3c7c2b3a26adb5ab76 Mon Sep 17 00:00:00 2001 From: Christian Huffman Date: Wed, 12 Aug 2020 14:55:42 -0400 Subject: [PATCH] Check for non-CSI PVs and mark not in use as appropriate --- pkg/common-controller/snapshot_controller.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/common-controller/snapshot_controller.go b/pkg/common-controller/snapshot_controller.go index 15a5131eb..a7f53714d 100644 --- a/pkg/common-controller/snapshot_controller.go +++ b/pkg/common-controller/snapshot_controller.go @@ -226,6 +226,16 @@ func (ctrl *csiSnapshotCommonController) isPVCwithFinalizerInUseByCurrentSnapsho return false } + // Check to see if the backing PV is created by a CSI driver. If not, then remove the Finalizer + pv, err := ctrl.getVolumeFromVolumeSnapshot(snapshot) + if err != nil { + klog.Infof("cannot get volume from snapshot [%s]: [%v]", snapshot.Name, err) + } + if pv.Spec.CSI == nil { + klog.Infof("cannot find CSI PersistentVolumeSource for volume %s: marking snapshot [%s] as not in use", pv.Name, snapshot.Name) + return false + } + if !utils.IsSnapshotReady(snapshot) { klog.V(2).Infof("PVC %s/%s is being used by snapshot %s/%s as source", pvc.Namespace, pvc.Name, snapshot.Namespace, snapshot.Name) return true