mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
Fix CSI initialization conflict
CSI is used by both the kubelet and kube-controller-manager. Both components will initialize the csiPlugin with different VolumeHost objects. The csiPlugin will then assign a global variable for the node info manager. It is then possible that the kubelet gets the credentials of the kube-controller-manager and that will cause CSI to fail.
This commit is contained in:
parent
b31fb2af18
commit
3e331cded8
@ -253,18 +253,22 @@ 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)
|
||||||
|
|
||||||
// This function prevents Kubelet from posting Ready status until CSINode
|
// This function prevents Kubelet from posting Ready status until CSINode
|
||||||
// is both installed and initialized
|
// is both installed and initialized
|
||||||
if err := initializeCSINode(host); err != nil {
|
if err := initializeCSINode(host, localNim); err != nil {
|
||||||
return errors.New(log("failed to initialize CSINode: %v", err))
|
return errors.New(log("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 CSINode initialization, not running on kubelet")
|
klog.V(4).Info("Cast from VolumeHost to KubeletVolumeHost failed. Skipping CSINode initialization, not running on kubelet")
|
||||||
|
Loading…
Reference in New Issue
Block a user