diff --git a/cmd/csi-provisioner/main.go b/cmd/csi-provisioner/main.go index 53dfd29..9d136dd 100644 --- a/cmd/csi-provisioner/main.go +++ b/cmd/csi-provisioner/main.go @@ -128,6 +128,7 @@ func main() { factory := informers.NewSharedInformerFactory(clientset, ResyncPeriodOfCsiNodeInformer) + driverLister := factory.Storage().V1().CSIDrivers().Lister() scLister := factory.Storage().V1().StorageClasses().Lister() claimLister := factory.Core().V1().PersistentVolumeClaims().Lister() csiNodeLister := factory.Storage().V1().CSINodes().Lister() @@ -149,7 +150,7 @@ func main() { // controller.VolumesInformer(volumeInformer), } - csiProvisioner := provisioner.NewProvisioner(ctx, clientset, scLister, csiNodeLister, nodeLister, claimLister) + csiProvisioner := provisioner.NewProvisioner(ctx, clientset, driverLister, scLister, csiNodeLister, nodeLister, claimLister) // Prepare http endpoint for metrics + leader election healthz mux := http.NewServeMux() diff --git a/pkg/provisioner/provisioner.go b/pkg/provisioner/provisioner.go index 4ba92ed..d847a2f 100644 --- a/pkg/provisioner/provisioner.go +++ b/pkg/provisioner/provisioner.go @@ -59,6 +59,7 @@ type HybridProvisioner struct { backoff wait.Backoff + driverLister storagelistersv1.CSIDriverLister scLister storagelistersv1.StorageClassLister csiNodeLister storagelistersv1.CSINodeLister nodeLister corelisters.NodeLister @@ -69,6 +70,7 @@ type HybridProvisioner struct { func NewProvisioner( ctx context.Context, client kubernetes.Interface, + driverLister storagelistersv1.CSIDriverLister, scLister storagelistersv1.StorageClassLister, csiNodeLister storagelistersv1.CSINodeLister, nodeLister corelisters.NodeLister, @@ -84,6 +86,7 @@ func NewProvisioner( Steps: defaultCreateProvisionedPVRetryCount, }, + driverLister: driverLister, scLister: scLister, csiNodeLister: csiNodeLister, nodeLister: nodeLister, @@ -159,6 +162,11 @@ func (p *HybridProvisioner) getStorageClassFromNode(selectedNode *corev1.Node, s continue } + if driver, err := p.driverLister.Get(class.Provisioner); err != nil || driver == nil { + // Provisioner is not a CSI driver + return class, nil // nolint: nilerr + } + for _, driver := range selectedCSINode.Spec.Drivers { if driver.Name == class.Provisioner { return class, nil