Skip to content

PVC finalizer not removed if invalid VolumeSnapshots with missing ReadyToUse field exist in the namespace #1305

@vasu81in

Description

@vasu81in

What happened:

The snapshot.storage.kubernetes.io/pvc-as-source-protection finalizer is not removed from a PersistentVolumeClaim (PVC) if there are other VolumeSnapshot objects in the same namespace referencing that PVC that never reach status.readyToUse: true. This causes delete PVC to get stuck in a Terminating state even though the valid snapshots have completed and been deleted.

What you expected to happen:
The finalizer should be removed from the PVC once the only valid VolumeSnapshot referencing it reaches ReadyToUse: true and is no longer present. Invalid VolumeSnapshot objects (e.g., those with incorrect or non-existent VolumeSnapshotClass) that never transition to ReadyToUse should not block finalizer removal from the PVC.

How to reproduce it:

Create multiple VolumeSnapshot objects pointing to the same PVC, but use a non-existent VolumeSnapshotClass for some of them. These will never transition to ReadyToUse: true.

Create a valid VolumeSnapshot referencing the same PVC using a working VolumeSnapshotClass.

Observe that the pvc-as-source-protection finalizer gets added to the PVC.

The valid VolumeSnapshot will complete (ReadyToUse: true), and may even be deleted.

However, the PVC’s finalizer is never removed, due to the lingering invalid snapshots.

Deleting the invalid VolumeSnapshots causes the finalizer to be cleaned up, only if done in the correct order (invalid → valid).

Anything else we need to know?:

The IsSnapshotReady() function checks if status.readyToUse is true, but when the field is unset (e.g. due to invalid VolumeSnapshotClass or a snapshot controller not updating the status), the snapshot is treated as still in use. As a result, finalizer removal is blocked, even if the snapshot never succeeded and never will.

if snap.Spec.Source.PersistentVolumeClaimName != nil &&
pvc.Name == *snap.Spec.Source.PersistentVolumeClaimName &&
!utils.IsSnapshotReady(snap) {
return true
}

This considers any snapshot referencing the PVC, and if its ReadyToUse field is false or missing, it blocks finalizer removal even for broken or misconfigured snapshots.

Environment:

  • Kubernetes version v1.32.2
  • snapshot-controller: v6.3.3
  • OS: any

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions