mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #108066 from marseel/dont_check_type_in_hostvolule_in_kubemark
Turn off volumehost type check in kubemark clusters
This commit is contained in:
commit
37a0b1a321
@ -72,7 +72,7 @@ func volumePlugins() []volume.VolumePlugin {
|
|||||||
allPlugins := []volume.VolumePlugin{}
|
allPlugins := []volume.VolumePlugin{}
|
||||||
allPlugins = append(allPlugins, emptydir.ProbeVolumePlugins()...)
|
allPlugins = append(allPlugins, emptydir.ProbeVolumePlugins()...)
|
||||||
allPlugins = append(allPlugins, git_repo.ProbeVolumePlugins()...)
|
allPlugins = append(allPlugins, git_repo.ProbeVolumePlugins()...)
|
||||||
allPlugins = append(allPlugins, hostpath.ProbeVolumePlugins(volume.VolumeConfig{})...)
|
allPlugins = append(allPlugins, hostpath.FakeProbeVolumePlugins(volume.VolumeConfig{})...)
|
||||||
allPlugins = append(allPlugins, nfs.ProbeVolumePlugins(volume.VolumeConfig{})...)
|
allPlugins = append(allPlugins, nfs.ProbeVolumePlugins(volume.VolumeConfig{})...)
|
||||||
allPlugins = append(allPlugins, secret.ProbeVolumePlugins()...)
|
allPlugins = append(allPlugins, secret.ProbeVolumePlugins()...)
|
||||||
allPlugins = append(allPlugins, iscsi.ProbeVolumePlugins()...)
|
allPlugins = append(allPlugins, iscsi.ProbeVolumePlugins()...)
|
||||||
|
@ -47,9 +47,20 @@ func ProbeVolumePlugins(volumeConfig volume.VolumeConfig) []volume.VolumePlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FakeProbeVolumePlugins(volumeConfig volume.VolumeConfig) []volume.VolumePlugin {
|
||||||
|
return []volume.VolumePlugin{
|
||||||
|
&hostPathPlugin{
|
||||||
|
host: nil,
|
||||||
|
config: volumeConfig,
|
||||||
|
noTypeChecker: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type hostPathPlugin struct {
|
type hostPathPlugin struct {
|
||||||
host volume.VolumeHost
|
host volume.VolumeHost
|
||||||
config volume.VolumeConfig
|
config volume.VolumeConfig
|
||||||
|
noTypeChecker bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ volume.VolumePlugin = &hostPathPlugin{}
|
var _ volume.VolumePlugin = &hostPathPlugin{}
|
||||||
@ -121,10 +132,11 @@ func (plugin *hostPathPlugin) NewMounter(spec *volume.Spec, pod *v1.Pod, opts vo
|
|||||||
return nil, fmt.Errorf("plugin volume host does not implement KubeletVolumeHost interface")
|
return nil, fmt.Errorf("plugin volume host does not implement KubeletVolumeHost interface")
|
||||||
}
|
}
|
||||||
return &hostPathMounter{
|
return &hostPathMounter{
|
||||||
hostPath: &hostPath{path: path, pathType: pathType},
|
hostPath: &hostPath{path: path, pathType: pathType},
|
||||||
readOnly: readOnly,
|
readOnly: readOnly,
|
||||||
mounter: plugin.host.GetMounter(plugin.GetPluginName()),
|
mounter: plugin.host.GetMounter(plugin.GetPluginName()),
|
||||||
hu: kvh.GetHostUtil(),
|
hu: kvh.GetHostUtil(),
|
||||||
|
noTypeChecker: plugin.noTypeChecker,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,9 +215,10 @@ func (hp *hostPath) GetPath() string {
|
|||||||
|
|
||||||
type hostPathMounter struct {
|
type hostPathMounter struct {
|
||||||
*hostPath
|
*hostPath
|
||||||
readOnly bool
|
readOnly bool
|
||||||
mounter mount.Interface
|
mounter mount.Interface
|
||||||
hu hostutil.HostUtils
|
hu hostutil.HostUtils
|
||||||
|
noTypeChecker bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ volume.Mounter = &hostPathMounter{}
|
var _ volume.Mounter = &hostPathMounter{}
|
||||||
@ -235,7 +248,11 @@ func (b *hostPathMounter) SetUp(mounterArgs volume.MounterArgs) error {
|
|||||||
if *b.pathType == v1.HostPathUnset {
|
if *b.pathType == v1.HostPathUnset {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return checkType(b.GetPath(), b.pathType, b.hu)
|
if b.noTypeChecker {
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
return checkType(b.GetPath(), b.pathType, b.hu)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetUpAt does not make sense for host paths - probably programmer error.
|
// SetUpAt does not make sense for host paths - probably programmer error.
|
||||||
|
@ -86,7 +86,7 @@ func TestGetAccessModes(t *testing.T) {
|
|||||||
func TestRecycler(t *testing.T) {
|
func TestRecycler(t *testing.T) {
|
||||||
plugMgr := volume.VolumePluginMgr{}
|
plugMgr := volume.VolumePluginMgr{}
|
||||||
pluginHost := volumetest.NewFakeKubeletVolumeHost(t, "/tmp/fake", nil, nil)
|
pluginHost := volumetest.NewFakeKubeletVolumeHost(t, "/tmp/fake", nil, nil)
|
||||||
plugMgr.InitPlugins([]volume.VolumePlugin{&hostPathPlugin{nil, volume.VolumeConfig{}}}, nil, pluginHost)
|
plugMgr.InitPlugins([]volume.VolumePlugin{&hostPathPlugin{nil, volume.VolumeConfig{}, false}}, nil, pluginHost)
|
||||||
|
|
||||||
spec := &volume.Spec{PersistentVolume: &v1.PersistentVolume{Spec: v1.PersistentVolumeSpec{PersistentVolumeSource: v1.PersistentVolumeSource{HostPath: &v1.HostPathVolumeSource{Path: "/foo"}}}}}
|
spec := &volume.Spec{PersistentVolume: &v1.PersistentVolume{Spec: v1.PersistentVolumeSpec{PersistentVolumeSource: v1.PersistentVolumeSource{HostPath: &v1.HostPathVolumeSource{Path: "/foo"}}}}}
|
||||||
_, err := plugMgr.FindRecyclablePluginBySpec(spec)
|
_, err := plugMgr.FindRecyclablePluginBySpec(spec)
|
||||||
|
Loading…
Reference in New Issue
Block a user