...
1
2
3
4
19
20 package app
21
22 import (
23
24 _ "k8s.io/kubernetes/pkg/credentialprovider/gcp"
25
26 "k8s.io/component-base/featuregate"
27 "k8s.io/csi-translation-lib/plugins"
28 "k8s.io/klog/v2"
29 "k8s.io/kubernetes/pkg/features"
30 "k8s.io/kubernetes/pkg/volume"
31 "k8s.io/kubernetes/pkg/volume/csimigration"
32 "k8s.io/kubernetes/pkg/volume/portworx"
33 "k8s.io/kubernetes/pkg/volume/rbd"
34 )
35
36 type probeFn func() []volume.VolumePlugin
37
38 func appendPluginBasedOnFeatureFlags(plugins []volume.VolumePlugin, inTreePluginName string,
39 featureGate featuregate.FeatureGate, pluginInfo pluginInfo) ([]volume.VolumePlugin, error) {
40 _, err := csimigration.CheckMigrationFeatureFlags(featureGate, pluginInfo.pluginMigrationFeature, pluginInfo.pluginUnregisterFeature)
41 if err != nil {
42 klog.InfoS("Unexpected CSI Migration Feature Flags combination detected, CSI Migration may not take effect", "err", err)
43
44 }
45
46
47
48 if featureGate.Enabled(pluginInfo.pluginUnregisterFeature) {
49 klog.InfoS("Skipped registration of plugin since feature flag is enabled", "pluginName", inTreePluginName, "featureFlag", pluginInfo.pluginUnregisterFeature)
50 return plugins, nil
51 }
52
53 plugins = append(plugins, pluginInfo.pluginProbeFunction()...)
54 return plugins, nil
55 }
56
57 type pluginInfo struct {
58 pluginMigrationFeature featuregate.Feature
59 pluginUnregisterFeature featuregate.Feature
60 pluginProbeFunction probeFn
61 }
62
63 func appendLegacyProviderVolumes(allPlugins []volume.VolumePlugin, featureGate featuregate.FeatureGate) ([]volume.VolumePlugin, error) {
64 pluginMigrationStatus := make(map[string]pluginInfo)
65 pluginMigrationStatus[plugins.PortworxVolumePluginName] = pluginInfo{pluginMigrationFeature: features.CSIMigrationPortworx, pluginUnregisterFeature: features.InTreePluginPortworxUnregister, pluginProbeFunction: portworx.ProbeVolumePlugins}
66 pluginMigrationStatus[plugins.RBDVolumePluginName] = pluginInfo{pluginMigrationFeature: features.CSIMigrationRBD, pluginUnregisterFeature: features.InTreePluginRBDUnregister, pluginProbeFunction: rbd.ProbeVolumePlugins}
67 var err error
68 for pluginName, pluginInfo := range pluginMigrationStatus {
69 allPlugins, err = appendPluginBasedOnFeatureFlags(allPlugins, pluginName, featureGate, pluginInfo)
70 if err != nil {
71 return allPlugins, err
72 }
73 }
74 return allPlugins, nil
75 }
76
View as plain text