Skip to content
Open
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
7 changes: 6 additions & 1 deletion pkg/common-controller/snapshot_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,12 @@ func (ctrl *csiSnapshotCommonController) isPVCBeingUsed(pvc *v1.PersistentVolume
klog.V(4).Infof("Skipping static bound snapshot %s when checking PVC %s/%s", snap.Name, pvc.Namespace, pvc.Name)
continue
}
if snap.Spec.Source.PersistentVolumeClaimName != nil && pvc.Name == *snap.Spec.Source.PersistentVolumeClaimName && !utils.IsSnapshotReady(snap) {

if snap.Spec.Source.PersistentVolumeClaimName != nil &&
pvc.Name == *snap.Spec.Source.PersistentVolumeClaimName &&
!utils.IsSnapshotReady(snap) &&
utils.HasSnapshotFinalizer(snap, utils.PVCFinalizer) {

klog.V(2).Infof("Keeping PVC %s/%s, it is used by snapshot %s/%s", pvc.Namespace, pvc.Name, snap.Namespace, snap.Name)
return true
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,15 @@ func IsBoundVolumeSnapshotContentNameSet(snapshot *crdv1.VolumeSnapshot) bool {
return true
}

func HasSnapshotFinalizer(snapshot *crdv1.VolumeSnapshot, finalizer string) bool {
for _, f := range snapshot.ObjectMeta.Finalizers {
if f == finalizer {
return true
}
}
return false
}

func IsSnapshotReady(snapshot *crdv1.VolumeSnapshot) bool {
if snapshot.Status == nil || snapshot.Status.ReadyToUse == nil || *snapshot.Status.ReadyToUse == false {
return false
Expand Down