Skip to content

Commit

Permalink
feat: support non csidriver plugin
Browse files Browse the repository at this point in the history
Support for the rancher.io/local-path storage class.
It is not compatible with the CSI Driver.

Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
  • Loading branch information
sergelogvinov committed Jan 10, 2025
1 parent 88ede53 commit e881c8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/csi-provisioner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions pkg/provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type HybridProvisioner struct {

backoff wait.Backoff

driverLister storagelistersv1.CSIDriverLister
scLister storagelistersv1.StorageClassLister
csiNodeLister storagelistersv1.CSINodeLister
nodeLister corelisters.NodeLister
Expand All @@ -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,
Expand All @@ -84,6 +86,7 @@ func NewProvisioner(
Steps: defaultCreateProvisionedPVRetryCount,
},

driverLister: driverLister,
scLister: scLister,
csiNodeLister: csiNodeLister,
nodeLister: nodeLister,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e881c8a

Please sign in to comment.