VolumeSnapshot deletion stuck with error "Snapshot is being used to restore a PVC" on the Supervisor after a failed backup
search cancel

VolumeSnapshot deletion stuck with error "Snapshot is being used to restore a PVC" on the Supervisor after a failed backup

book

Article ID: 424781

calendar_today

Updated On:

Products

VMware vCenter Server VMware vSphere Kubernetes Service VMware vSphere ESXi

Issue/Introduction

  • A failed backup operation left a stale VolumeSnapshot on the Guest Cluster.

  • Deleting the VolumeSnapshot on the Guest Cluster hangs indefinitely.

  • The VolumeSnapshotContent on the Guest Cluster displays the generic warning: Warning SnapshotDeleteError ... csi-snapshotter csi.vsphere.vmware.com Failed to delete snapshot

  • There are no PVCs on the Guest Cluster that currently reference the stuck VolumeSnapshot.

  • Inspecting the corresponding VolumeSnapshot on the vSphere Supervisor Cluster reveals the following warning event: Warning SnapshotDeletePending ... snapshot-controller Snapshot is being used to restore a PVC

Environment

VKS Guest Cluster with backup including Velero, Commvault

Cause

The VolumeSnapshot cannot be deleted because a stale, pending PersistentVolumeClaim (PVC) on the vSphere Supervisor Cluster is still referencing the snapshot as its data source.
This typically occurs when a backup operation (such as Commvault) times out, leaving the temporary PVC behind on the Supervisor even though the corresponding resources were cleaned up on the Guest Cluster.

Resolution

Follow these steps to identify the specific resource ID and remove the stale dependency on the vSphere Supervisor Cluster.

1. Retrieve the Snapshot Handle from the Guest Cluster

On the Guest Cluster, identify the VolumeSnapshotContent object that is stuck in deletion. Run the following command to extract the Snapshot Handle.
This ID represents the actual name of the VolumeSnapshot resource on the Supervisor Cluster.

# Replace <snapcontent-name> with the name from your error logs
kubectl get volumesnapshotcontent <snapcontent-name> -o jsonpath='{.status.snapshotHandle}'

Note the output ID. It will look similar to this format: ########-####-####-####-############-########-####-####-####-############

2. Verify the Lock on Supervisor VolumeSnapshot

Log in to the vSphere Supervisor Cluster.
Use the ID obtained in Step 1 to inspect the snapshot resource.

kubectl describe volumesnapshot -n <supervisor-namespace> <snapshot-handle-id>

Confirm the presence of the warning event: Warning SnapshotDeletePending ... Snapshot is being used to restore a PVC

3. Identify the Stale PVC on the Supervisor Cluster


You must find the specific Pending PVC that is referencing this snapshot handle.
Run the following command to dump the PVCs and search for the handle ID.

kubectl get pvc -n <supervisor-namespace> -o yaml | grep <snapshot-handle-id> -B 15 -A 5

Alternatively, you can open the full list in a pager:

kubectl get pvc -n <supervisor-namespace> -o yaml | less

Look for a PVC entry where status.phase is Pending and the spec.dataSource.name matches your snapshot handle:

spec:
  dataSource:
    apiGroup: snapshot.storage.k8s.io
    kind: VolumeSnapshot
    # The name below will match the Snapshot Handle ID found in Step 1
    name: ########-####-####-####-############-########-####-####-####-############ 
status:
  phase: Pending

4. Delete the pending snapshot with the below command to retrigger a snapshot consolidation action.

Note that this action will take some time until the data is consolidated, the larger the size of the volumesnapshot, the longer time it will take. You will also see a snapshot deletion event triggerred in the vCenter.

kubectl delete volumesnapshot -n <namespace> <guest-cluster-snapshot-name> 

Note: You may observe that the delete task may get stuck in certain situations, especially if a previous delete operation was sent to the object before. In that case refer to the Alternative Method below:

5. Delete the Pending PVC
Delete the stale PVCs identified in Step 3.

kubectl delete pvc -n <supervisor-namespace> <pvc-name>

6. Verification

Once the PVC is deleted, the Supervisor will automatically release the lock on the snapshot after a timeout.
The VolumeSnapshot will disappear from the Supervisor, and subsequently, the stuck VolumeSnapshotContent on the Guest Cluster will be successfully deleted.

Alternative Method:

1. First get the PVC with the obtained snaphot-handle-id, from supervisor context:

kubectl get pvc -n <supervisor-namespace> -o yaml | grep <snapshot-handle-id> -B 15 -A 5
kubectl delete pvc -n <supervisor-namespace> <pvc-name>

2. Within the guest cluster context, delete the volumesnapshot from the velero-namespace

kubectl delete volumesnapshot -n <velero-namespace> <guest-cluster-snapshot-name> 

 

Additional Information

Preventive actions:
To prevent the accumulation of stale VolumeSnapshots and pending PVCs, the following preventative measures can be taken.
Note: This is not an exhaustive list and assumes the underlying storage backend/compute to process that storage IO is already healthy and issues originating from those stacks (storage latency, driver, configuration issues) are ruled out:

1. Adjust Backup Software Timeouts (Diagnostic Validation) While application timeouts (e.g., Commvault) are strictly configured within the backup vendor's UI or policy, you can validate if the vSphere CSI driver is dropping connections due to client-side timeouts by inspecting the csi-snapshotter logs on the Guest Cluster for context cancellation or timeout errors.

# Execute against the Guest Cluster
kubectl logs deployment/vsphere-csi-controller -n vmware-system-csi -c csi-snapshotter --tail=200 | grep -iE "timeout|context deadline exceeded|context canceled"

And if there are timeouts occuring, for example for Velero you can add parameters for timeouts for csi-snapshot-timeout, data-mover-prepare-timeout

https://velero.io/docs/main/examples/
https://velero.io/docs/main/csi-snapshot-data-movement/

You can refer to your backup vendor's documentation to modify the timeout values.

2. Validate Supervisor Namespace Storage Quotas Storage limits imposed on the Supervisor Namespace can prevent the temporary backup PVC from binding. Check for storage capacity constraints to confirm if the quota is blocking PVC allocation.

# Execute against the Supervisor Cluster

# List all resource quotas in the Supervisor namespace
kubectl get resourcequota -n <supervisor-namespace>

# Describe the quota to view specific storage usage vs. limits (e.g., requests.storage)
kubectl describe resourcequota -n <supervisor-namespace>

3. Implement Orphaned PVC Monitoring To proactively identify stale backup PVCs that have failed to clean up, use the following commands against the Supervisor Cluster. These can be integrated into custom monitoring scripts or cron jobs.

List all pending PVCs sorted by oldest creation time first:

# Execute against the Supervisor Cluster
kubectl get pvc -n <supervisor-namespace> --field-selector status.phase=Pending --sort-by=.metadata.creationTimestamp

Advanced query utilizing jq to explicitly isolate and output Pending PVCs that have existed for greater than 60 minutes (3600 seconds):

# Execute against the Supervisor Cluster (Requires jq)
kubectl get pvc -n <supervisor-namespace> --field-selector status.phase=Pending -o json | jq -r '.items[] | select((now - (.metadata.creationTimestamp | fromdateiso8601)) > 3600) | "Stale PVC: \(.metadata.name) | Created: \(.metadata.creationTimestamp)"'


Commvault Documentation :
Backup Process for Kubernetes