Skip to content

Commit

Permalink
Check for non-CSI PVs and mark not in use as appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
huffmanca committed Aug 12, 2020
1 parent 4e0d027 commit 76198b2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/common-controller/snapshot_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 76198b2

Please sign in to comment.