|
|
@ -23,7 +23,6 @@ import (
|
|
|
|
"path"
|
|
|
|
"path"
|
|
|
|
"sort"
|
|
|
|
"sort"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
@ -64,12 +63,6 @@ const (
|
|
|
|
csiResyncPeriod = time.Minute
|
|
|
|
csiResyncPeriod = time.Minute
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
|
|
|
WaitForValidHostName bool
|
|
|
|
|
|
|
|
csiPluginInstance *csiPlugin
|
|
|
|
|
|
|
|
csiPluginLock sync.Mutex
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var deprecatedSocketDirVersions = []string{"0.1.0", "0.2.0", "0.3.0", "0.4.0"}
|
|
|
|
var deprecatedSocketDirVersions = []string{"0.1.0", "0.2.0", "0.3.0", "0.4.0"}
|
|
|
|
|
|
|
|
|
|
|
|
type csiPlugin struct {
|
|
|
|
type csiPlugin struct {
|
|
|
@ -86,18 +79,11 @@ const ephemeralDriverMode driverMode = "ephemeral"
|
|
|
|
|
|
|
|
|
|
|
|
// ProbeVolumePlugins returns implemented plugins
|
|
|
|
// ProbeVolumePlugins returns implemented plugins
|
|
|
|
func ProbeVolumePlugins() []volume.VolumePlugin {
|
|
|
|
func ProbeVolumePlugins() []volume.VolumePlugin {
|
|
|
|
csiPluginLock.Lock()
|
|
|
|
p := &csiPlugin{
|
|
|
|
defer csiPluginLock.Unlock()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if csiPluginInstance != nil {
|
|
|
|
|
|
|
|
return []volume.VolumePlugin{csiPluginInstance}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
csiPluginInstance = &csiPlugin{
|
|
|
|
|
|
|
|
host: nil,
|
|
|
|
host: nil,
|
|
|
|
blockEnabled: utilfeature.DefaultFeatureGate.Enabled(features.CSIBlockVolume),
|
|
|
|
blockEnabled: utilfeature.DefaultFeatureGate.Enabled(features.CSIBlockVolume),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return []volume.VolumePlugin{csiPluginInstance}
|
|
|
|
return []volume.VolumePlugin{p}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// volume.VolumePlugin methods
|
|
|
|
// volume.VolumePlugin methods
|
|
|
@ -221,21 +207,6 @@ func (h *RegistrationHandler) DeRegisterPlugin(pluginName string) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (p *csiPlugin) Init(host volume.VolumeHost) error {
|
|
|
|
func (p *csiPlugin) Init(host volume.VolumeHost) error {
|
|
|
|
csiPluginLock.Lock()
|
|
|
|
|
|
|
|
defer csiPluginLock.Unlock()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if WaitForValidHostName && host.GetHostName() == "" {
|
|
|
|
|
|
|
|
for {
|
|
|
|
|
|
|
|
if p.host != nil {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
csiPluginLock.Unlock()
|
|
|
|
|
|
|
|
time.Sleep(time.Second)
|
|
|
|
|
|
|
|
klog.Infof("Waiting for CSI volume hostname")
|
|
|
|
|
|
|
|
csiPluginLock.Lock()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p.host = host
|
|
|
|
p.host = host
|
|
|
|
|
|
|
|
|
|
|
|
if utilfeature.DefaultFeatureGate.Enabled(features.CSIDriverRegistry) {
|
|
|
|
if utilfeature.DefaultFeatureGate.Enabled(features.CSIDriverRegistry) {
|
|
|
@ -274,21 +245,25 @@ func (p *csiPlugin) Init(host volume.VolumeHost) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Initializing the label management channels
|
|
|
|
// Initializing the label management channels
|
|
|
|
nim = nodeinfomanager.NewNodeInfoManager(host.GetNodeName(), host, migratedPlugins)
|
|
|
|
localNim := nodeinfomanager.NewNodeInfoManager(host.GetNodeName(), host, migratedPlugins)
|
|
|
|
|
|
|
|
|
|
|
|
if utilfeature.DefaultFeatureGate.Enabled(features.CSINodeInfo) &&
|
|
|
|
if utilfeature.DefaultFeatureGate.Enabled(features.CSINodeInfo) &&
|
|
|
|
utilfeature.DefaultFeatureGate.Enabled(features.CSIMigration) {
|
|
|
|
utilfeature.DefaultFeatureGate.Enabled(features.CSIMigration) {
|
|
|
|
// This function prevents Kubelet from posting Ready status until CSINodeInfo
|
|
|
|
// This function prevents Kubelet from posting Ready status until CSINodeInfo
|
|
|
|
// is both installed and initialized
|
|
|
|
// is both installed and initialized
|
|
|
|
if err := initializeCSINode(host); err != nil {
|
|
|
|
if err := initializeCSINode(host, localNim); err != nil {
|
|
|
|
return fmt.Errorf("failed to initialize CSINodeInfo: %v", err)
|
|
|
|
return fmt.Errorf("failed to initialize CSINodeInfo: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _, ok := host.(volume.KubeletVolumeHost); ok {
|
|
|
|
|
|
|
|
nim = localNim
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func initializeCSINode(host volume.VolumeHost) error {
|
|
|
|
func initializeCSINode(host volume.VolumeHost, nim nodeinfomanager.Interface) error {
|
|
|
|
kvh, ok := host.(volume.KubeletVolumeHost)
|
|
|
|
kvh, ok := host.(volume.KubeletVolumeHost)
|
|
|
|
if !ok {
|
|
|
|
if !ok {
|
|
|
|
klog.V(4).Info("Cast from VolumeHost to KubeletVolumeHost failed. Skipping CSINodeInfo initialization, not running on kubelet")
|
|
|
|
klog.V(4).Info("Cast from VolumeHost to KubeletVolumeHost failed. Skipping CSINodeInfo initialization, not running on kubelet")
|
|
|
|