external-snapshotter: VolumeSnapshot cannot be deleted when the VolumeSnapshotClass is missing

What happened: Checking the changelog, there is #275 which should allow deletion of VolumeSnapshot when the VolumeSnapshotClass is missing, but this is not happening.

What you expected to happen: I would expect to be able to delete VolumeSnapshot when its .spec.volumeSnapshotClassName is missing.

How to reproduce it (as minimally and precisely as possible):

  1. Create PVC
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: source-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 6Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: source-pod
spec:
  containers:
  - name: busybox
    image: busybox
    command: ["/bin/sh", "-c"]
    args: ["touch /demo/data/sample-file.txt && sleep 3000"]
    volumeMounts:
    - name: source-data
      mountPath: /demo/data
  volumes:
  - name: source-data
    persistentVolumeClaim:
      claimName: source-pvc
      readOnly: false
  1. Create a VolumeSnapshot.
apiVersion: snapshot.storage.k8s.io/v1beta1
kind: VolumeSnapshotClass
metadata:
  annotations:
    snapshot.storage.kubernetes.io/is-default-class: "true"
  name: default-snapshot-class
driver: ebs.csi.aws.com
deletionPolicy: Delete
---
apiVersion: snapshot.storage.k8s.io/v1beta1
kind: VolumeSnapshot
metadata:
  name: snapshot-source-pvc
spec:
  volumeSnapshotClassName: default-snapshot-class
  source:
    persistentVolumeClaimName: source-pvc
  1. Delete the VolumeSnapshotClass.
$ k get volumesnapshotclasses.snapshot.storage.k8s.io
NAME                     DRIVER            DELETIONPOLICY   AGE
default-snapshot-class   ebs.csi.aws.com   Delete           2d2h

$ k delete volumesnapshotclasses.snapshot.storage.k8s.io default-snapshot-class
volumesnapshotclass.snapshot.storage.k8s.io "default-snapshot-class" deleted
  1. Delete the VolumeSnasphot and ensure its deletion fails:
$ k delete volumesnapshot snapshot-source-pvc
volumesnapshot.snapshot.storage.k8s.io "snapshot-source-pvc" deleted
$ k describe volumesnapshot snapshot-source-pvc

Events:
  Type     Reason                  Age    From                 Message
  ----     ------                  ----   ----                 -------
  Warning  GetSnapshotClassFailed  8m26s  snapshot-controller  Failed to get snapshot class with error volumesnapshotclass.snapshot.storage.k8s.io "default-snapshot-class" not found

Anything else we need to know?:

Environment:

  • Version: v2.1.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (12 by maintainers)

Most upvoted comments

I’m working on the release.

#275 only fixed it in the snapshot controller. There’s also a place in the csi snapshotter sidecar that needs to be fixed. There’s WIP PR to address this: https://github.com/kubernetes-csi/external-snapshotter/pull/287