Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support non csidriver plugin #6

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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