diff --git a/pkg/kubemark/hollow_kubelet.go b/pkg/kubemark/hollow_kubelet.go index e3e35cecd00..739a55d9c39 100644 --- a/pkg/kubemark/hollow_kubelet.go +++ b/pkg/kubemark/hollow_kubelet.go @@ -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()...) diff --git a/pkg/volume/hostpath/host_path.go b/pkg/volume/hostpath/host_path.go index ece27cf21e3..bfdd20c7d41 100644 --- a/pkg/volume/hostpath/host_path.go +++ b/pkg/volume/hostpath/host_path.go @@ -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. diff --git a/pkg/volume/hostpath/host_path_test.go b/pkg/volume/hostpath/host_path_test.go index 9302e728df0..a77c642f9a8 100644 --- a/pkg/volume/hostpath/host_path_test.go +++ b/pkg/volume/hostpath/host_path_test.go @@ -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)