mirror of https://github.com/k3s-io/k3s
VolumeHost.GetNodeName method added for CSI fix
parent
8c1ee761d2
commit
7405159558
|
@ -603,3 +603,7 @@ func (adc *attachDetachController) addNodeToDswp(node *v1.Node, nodeName types.N
|
|||
func (adc *attachDetachController) GetNodeLabels() (map[string]string, error) {
|
||||
return nil, fmt.Errorf("GetNodeLabels() unsupported in Attach/Detach controller")
|
||||
}
|
||||
|
||||
func (adc *attachDetachController) GetNodeName() types.NodeName {
|
||||
return ""
|
||||
}
|
||||
|
|
|
@ -277,3 +277,7 @@ func (expc *expandController) GetConfigMapFunc() func(namespace, name string) (*
|
|||
func (expc *expandController) GetNodeLabels() (map[string]string, error) {
|
||||
return nil, fmt.Errorf("GetNodeLabels unsupported in expandController")
|
||||
}
|
||||
|
||||
func (expc *expandController) GetNodeName() types.NodeName {
|
||||
return ""
|
||||
}
|
||||
|
|
|
@ -108,3 +108,7 @@ func (adc *PersistentVolumeController) GetExec(pluginName string) mount.Exec {
|
|||
func (ctrl *PersistentVolumeController) GetNodeLabels() (map[string]string, error) {
|
||||
return nil, fmt.Errorf("GetNodeLabels() unsupported in PersistentVolumeController")
|
||||
}
|
||||
|
||||
func (ctrl *PersistentVolumeController) GetNodeName() types.NodeName {
|
||||
return ""
|
||||
}
|
||||
|
|
|
@ -188,6 +188,10 @@ func (kvh *kubeletVolumeHost) GetNodeLabels() (map[string]string, error) {
|
|||
return node.Labels, nil
|
||||
}
|
||||
|
||||
func (kvh *kubeletVolumeHost) GetNodeName() types.NodeName {
|
||||
return kvh.kubelet.nodeName
|
||||
}
|
||||
|
||||
func (kvh *kubeletVolumeHost) GetExec(pluginName string) mount.Exec {
|
||||
exec, err := kvh.getMountExec(pluginName)
|
||||
if err != nil {
|
||||
|
|
|
@ -303,6 +303,9 @@ type VolumeHost interface {
|
|||
|
||||
// Returns the labels on the node
|
||||
GetNodeLabels() (map[string]string, error)
|
||||
|
||||
// Returns the name of the node
|
||||
GetNodeName() types.NodeName
|
||||
}
|
||||
|
||||
// VolumePluginMgr tracks registered plugins.
|
||||
|
|
|
@ -53,6 +53,7 @@ type fakeVolumeHost struct {
|
|||
exec mount.Exec
|
||||
writer io.Writer
|
||||
nodeLabels map[string]string
|
||||
nodeName string
|
||||
}
|
||||
|
||||
func NewFakeVolumeHost(rootDir string, kubeClient clientset.Interface, plugins []VolumePlugin) *fakeVolumeHost {
|
||||
|
@ -69,6 +70,12 @@ func NewFakeVolumeHostWithNodeLabels(rootDir string, kubeClient clientset.Interf
|
|||
return volHost
|
||||
}
|
||||
|
||||
func NewFakeVolumeHostWithNodeName(rootDir string, kubeClient clientset.Interface, plugins []VolumePlugin, nodeName string) *fakeVolumeHost {
|
||||
volHost := newFakeVolumeHost(rootDir, kubeClient, plugins, nil)
|
||||
volHost.nodeName = nodeName
|
||||
return volHost
|
||||
}
|
||||
|
||||
func newFakeVolumeHost(rootDir string, kubeClient clientset.Interface, plugins []VolumePlugin, cloud cloudprovider.Interface) *fakeVolumeHost {
|
||||
host := &fakeVolumeHost{rootDir: rootDir, kubeClient: kubeClient, cloud: cloud}
|
||||
host.mounter = &mount.FakeMounter{}
|
||||
|
@ -177,6 +184,10 @@ func (f *fakeVolumeHost) GetNodeLabels() (map[string]string, error) {
|
|||
return f.nodeLabels, nil
|
||||
}
|
||||
|
||||
func (f *fakeVolumeHost) GetNodeName() types.NodeName {
|
||||
return types.NodeName(f.nodeName)
|
||||
}
|
||||
|
||||
func ProbeVolumePlugins(config VolumeConfig) []VolumePlugin {
|
||||
if _, ok := config.OtherAttributes["fake-property"]; ok {
|
||||
return []VolumePlugin{
|
||||
|
|
Loading…
Reference in New Issue