kubernetes-csi / external-snapshotter

Sidecar container that watches Kubernetes Snapshot CRD objects and triggers CreateSnapshot/DeleteSnapshot against a CSI endpoint.
Apache License 2.0
463 stars 361 forks source link

Controller does not detect new Volume[Group]SnapshotClass set as default #1099

Closed leonardoce closed 1 month ago

leonardoce commented 1 month ago

What happened:

If multiple default Volume[Group]SnapshotClasses are created before the external-snapshotter controller Pod starts, the controller will detect them correctly and when webhook is not installed dynamically provisioned VolumeSnapshot and VolumeGroupSnapshots will fail with:

apiVersion: groupsnapshot.storage.k8s.io/v1alpha1
kind: VolumeGroupSnapshot
metadata:
  name: new-groupsnapshot-demo
spec:
  source:
    selector:
      matchLabels:
        cnpg.io/instanceName: cluster-example-1
status:
  error:
    message: Failed to set default group snapshot class with error 2 default snapshot
      classes were found
    time: "2024-05-28T08:24:42Z"

This doesn't happen if the external-snapshotter controller starts with a correct configuration (having just one default class per CSI driver) and a new one is added later. In that case, the Volume[Group]Snapshot will be provisioned by the CSI driver specified in the Volume[Group]SnapshotClass that was present before the controller started.

What you expected to happen:

I expect the behavior to be the same, regardless of when the Volume[Group]SnapshotClass was created.

How to reproduce it:

On an empty cluster with just the hostpath provisioner installed, create one default VolumeSnapshotClass. Install the external-snapshotter controller and, when it's ready, create a new VolumeSnapshotClass.

You'll see the VolumeSnapshot objects being created from the first VolumeSnapshotClass you created and set as default.

leonardoce commented 1 month ago

/assign