mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +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 = append(allPlugins, emptydir.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, secret.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 {
|
||||
host volume.VolumeHost
|
||||
config volume.VolumeConfig
|
||||
host volume.VolumeHost
|
||||
config volume.VolumeConfig
|
||||
noTypeChecker bool
|
||||
}
|
||||
|
||||
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 &hostPathMounter{
|
||||
hostPath: &hostPath{path: path, pathType: pathType},
|
||||
readOnly: readOnly,
|
||||
mounter: plugin.host.GetMounter(plugin.GetPluginName()),
|
||||
hu: kvh.GetHostUtil(),
|
||||
hostPath: &hostPath{path: path, pathType: pathType},
|
||||
readOnly: readOnly,
|
||||
mounter: plugin.host.GetMounter(plugin.GetPluginName()),
|
||||
hu: kvh.GetHostUtil(),
|
||||
noTypeChecker: plugin.noTypeChecker,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -203,9 +215,10 @@ func (hp *hostPath) GetPath() string {
|
||||
|
||||
type hostPathMounter struct {
|
||||
*hostPath
|
||||
readOnly bool
|
||||
mounter mount.Interface
|
||||
hu hostutil.HostUtils
|
||||
readOnly bool
|
||||
mounter mount.Interface
|
||||
hu hostutil.HostUtils
|
||||
noTypeChecker bool
|
||||
}
|
||||
|
||||
var _ volume.Mounter = &hostPathMounter{}
|
||||
@ -235,7 +248,11 @@ func (b *hostPathMounter) SetUp(mounterArgs volume.MounterArgs) error {
|
||||
if *b.pathType == v1.HostPathUnset {
|
||||
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.
|
||||
|
@ -86,7 +86,7 @@ func TestGetAccessModes(t *testing.T) {
|
||||
func TestRecycler(t *testing.T) {
|
||||
plugMgr := volume.VolumePluginMgr{}
|
||||
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"}}}}}
|
||||
_, err := plugMgr.FindRecyclablePluginBySpec(spec)
|
||||
|
Loading…
Reference in New Issue
Block a user