Remove GetExec method from VolumeHost

Signed-off-by: carlory <baofa.fan@daocloud.io>
This commit is contained in:
carlory
2025-06-12 17:41:24 +08:00
parent f0dde38234
commit 85bc3cb096
18 changed files with 45 additions and 78 deletions

View File

@@ -26,7 +26,6 @@ import (
"k8s.io/klog/v2"
"k8s.io/mount-utils"
utilexec "k8s.io/utils/exec"
authenticationv1 "k8s.io/api/authentication/v1"
v1 "k8s.io/api/core/v1"
@@ -851,10 +850,6 @@ func (adc *attachDetachController) DeleteServiceAccountTokenFunc() func(types.UI
}
}
func (adc *attachDetachController) GetExec() utilexec.Interface {
return utilexec.New()
}
func (adc *attachDetachController) addNodeToDswp(node *v1.Node, nodeName types.NodeName) {
if _, exists := node.Annotations[volumeutil.ControllerManagedAttachAnnotation]; exists {
// Node specifies annotation indicating it should be managed by attach

View File

@@ -25,7 +25,6 @@ import (
"k8s.io/klog/v2"
"k8s.io/mount-utils"
utilexec "k8s.io/utils/exec"
authenticationv1 "k8s.io/api/authentication/v1"
v1 "k8s.io/api/core/v1"
@@ -411,10 +410,6 @@ func (expc *expandController) GetMounter() mount.Interface {
return nil
}
func (expc *expandController) GetExec() utilexec.Interface {
return utilexec.New()
}
func (expc *expandController) GetHostName() string {
return ""
}

View File

@@ -22,7 +22,6 @@ import (
"k8s.io/klog/v2"
"k8s.io/mount-utils"
utilexec "k8s.io/utils/exec"
authenticationv1 "k8s.io/api/authentication/v1"
v1 "k8s.io/api/core/v1"
@@ -118,10 +117,6 @@ func (ctrl *PersistentVolumeController) DeleteServiceAccountTokenFunc() func(typ
}
}
func (adc *PersistentVolumeController) GetExec() utilexec.Interface {
return utilexec.New()
}
func (ctrl *PersistentVolumeController) GetNodeLabels() (map[string]string, error) {
return nil, fmt.Errorf("GetNodeLabels() unsupported in PersistentVolumeController")
}

View File

@@ -30,7 +30,6 @@ import (
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util/subpath"
"k8s.io/mount-utils"
utilexec "k8s.io/utils/exec"
)
var _ volume.VolumeHost = &Controller{}
@@ -118,10 +117,6 @@ func (c *Controller) DeleteServiceAccountTokenFunc() func(types.UID) {
}
}
func (c *Controller) GetExec() utilexec.Interface {
return utilexec.New()
}
func (c *Controller) GetNodeLabels() (map[string]string, error) {
return nil, fmt.Errorf("GetNodeLabels() unsupported in SELinux controller")
}

View File

@@ -302,7 +302,3 @@ func (kvh *kubeletVolumeHost) GetNodeName() types.NodeName {
func (kvh *kubeletVolumeHost) GetEventRecorder() record.EventRecorder {
return kvh.kubelet.recorder
}
func (kvh *kubeletVolumeHost) GetExec() utilexec.Interface {
return kvh.exec
}

View File

@@ -46,8 +46,9 @@ import (
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/volume"
fakecsi "k8s.io/kubernetes/pkg/volume/csi/fake"
"k8s.io/kubernetes/pkg/volume/util"
volumetypes "k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/mount-utils"
testingexec "k8s.io/utils/exec/testing"
)
var (
@@ -1181,7 +1182,7 @@ func TestUnmounterTeardown(t *testing.T) {
}
// do a fake local mount
diskMounter := util.NewSafeFormatAndMountFromHost(plug.host)
diskMounter := mount.NewSafeFormatAndMount(plug.host.GetMounter(), &testingexec.FakeExec{DisableScripts: true})
device := "/fake/device"
if goruntime.GOOS == "windows" {
// We need disk numbers on Windows.
@@ -1238,7 +1239,7 @@ func TestUnmounterTeardownNoClientError(t *testing.T) {
}
// do a fake local mount
diskMounter := util.NewSafeFormatAndMountFromHost(plug.host)
diskMounter := mount.NewSafeFormatAndMount(plug.host.GetMounter(), &testingexec.FakeExec{DisableScripts: true})
device := "/fake/device"
if goruntime.GOOS == "windows" {
// We need disk numbers on Windows.

View File

@@ -30,6 +30,7 @@ import (
"k8s.io/kubernetes/pkg/volume"
volumeutil "k8s.io/kubernetes/pkg/volume/util"
"k8s.io/mount-utils"
"k8s.io/utils/exec"
)
type fcAttacher struct {
@@ -123,7 +124,7 @@ func (attacher *fcAttacher) MountDevice(spec *volume.Spec, devicePath string, de
options = volumeutil.AddSELinuxMountOption(options, mountArgs.SELinuxLabel)
}
if notMnt {
diskMounter := &mount.SafeFormatAndMount{Interface: mounter, Exec: attacher.host.GetExec()}
diskMounter := &mount.SafeFormatAndMount{Interface: mounter, Exec: exec.New()}
mountOptions := volumeutil.MountOptionFromSpec(spec, options...)
err = diskMounter.FormatAndMount(devicePath, deviceMountPath, volumeSource.FSType, mountOptions)
if err != nil {
@@ -178,7 +179,7 @@ func (detacher *fcDetacher) UnmountDevice(deviceMountPath string) error {
return nil
}
unMounter := volumeSpecToUnmounter(detacher.mounter, detacher.host)
unMounter := volumeSpecToUnmounter(detacher.mounter)
// The device is unmounted now. If UnmountDevice was retried, GetDeviceNameFromMount
// won't find any mount and won't return DetachDisk below.
// Therefore implement our own retry mechanism here.
@@ -247,19 +248,19 @@ func volumeSpecToMounter(spec *volume.Spec, host volume.VolumeHost) (*fcDiskMoun
fsType: fc.FSType,
volumeMode: volumeMode,
readOnly: readOnly,
mounter: volumeutil.NewSafeFormatAndMountFromHost(host),
mounter: mount.NewSafeFormatAndMount(host.GetMounter(), exec.New()),
deviceUtil: volumeutil.NewDeviceHandler(volumeutil.NewIOHandler()),
mountOptions: volumeutil.MountOptionFromSpec(spec),
}, nil
}
func volumeSpecToUnmounter(mounter mount.Interface, host volume.VolumeHost) *fcDiskUnmounter {
func volumeSpecToUnmounter(mounter mount.Interface) *fcDiskUnmounter {
return &fcDiskUnmounter{
fcDisk: &fcDisk{
io: &osIOHandler{},
},
mounter: mounter,
deviceUtil: volumeutil.NewDeviceHandler(volumeutil.NewIOHandler()),
exec: host.GetExec(),
exec: exec.New(),
}
}

View File

@@ -110,7 +110,7 @@ func (plugin *fcPlugin) GetAccessModes() []v1.PersistentVolumeAccessMode {
func (plugin *fcPlugin) NewMounter(spec *volume.Spec, pod *v1.Pod) (volume.Mounter, error) {
// Inject real implementations here, test through the internal function.
return plugin.newMounterInternal(spec, pod.UID, &fcUtil{}, plugin.host.GetMounter(), plugin.host.GetExec())
return plugin.newMounterInternal(spec, pod.UID, &fcUtil{}, plugin.host.GetMounter(), utilexec.New())
}
func (plugin *fcPlugin) newMounterInternal(spec *volume.Spec, podUID types.UID, manager diskManager, mounter mount.Interface, exec utilexec.Interface) (volume.Mounter, error) {
@@ -160,7 +160,7 @@ func (plugin *fcPlugin) NewBlockVolumeMapper(spec *volume.Spec, pod *v1.Pod) (vo
if pod != nil {
uid = pod.UID
}
return plugin.newBlockVolumeMapperInternal(spec, uid, &fcUtil{}, plugin.host.GetMounter(), plugin.host.GetExec())
return plugin.newBlockVolumeMapperInternal(spec, uid, &fcUtil{}, plugin.host.GetMounter(), utilexec.New())
}
func (plugin *fcPlugin) newBlockVolumeMapperInternal(spec *volume.Spec, podUID types.UID, manager diskManager, mounter mount.Interface, exec utilexec.Interface) (volume.BlockVolumeMapper, error) {
@@ -200,7 +200,7 @@ func (plugin *fcPlugin) newBlockVolumeMapperInternal(spec *volume.Spec, podUID t
func (plugin *fcPlugin) NewUnmounter(volName string, podUID types.UID) (volume.Unmounter, error) {
// Inject real implementations here, test through the internal function.
return plugin.newUnmounterInternal(volName, podUID, &fcUtil{}, plugin.host.GetMounter(), plugin.host.GetExec())
return plugin.newUnmounterInternal(volName, podUID, &fcUtil{}, plugin.host.GetMounter(), utilexec.New())
}
func (plugin *fcPlugin) newUnmounterInternal(volName string, podUID types.UID, manager diskManager, mounter mount.Interface, exec utilexec.Interface) (volume.Unmounter, error) {
@@ -219,7 +219,7 @@ func (plugin *fcPlugin) newUnmounterInternal(volName string, podUID types.UID, m
}
func (plugin *fcPlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
return plugin.newUnmapperInternal(volName, podUID, &fcUtil{}, plugin.host.GetExec())
return plugin.newUnmapperInternal(volName, podUID, &fcUtil{}, utilexec.New())
}
func (plugin *fcPlugin) newUnmapperInternal(volName string, podUID types.UID, manager diskManager, exec utilexec.Interface) (volume.BlockVolumeUnmapper, error) {

View File

@@ -21,6 +21,7 @@ import (
"k8s.io/klog/v2"
"k8s.io/mount-utils"
"k8s.io/utils/exec"
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/volume"
@@ -67,7 +68,7 @@ func (a *attacherDefaults) MountDevice(spec *volume.Spec, devicePath string, dev
options = append(options, "rw")
}
diskMounter := &mount.SafeFormatAndMount{Interface: mounter, Exec: a.plugin.host.GetExec()}
diskMounter := &mount.SafeFormatAndMount{Interface: mounter, Exec: exec.New()}
return diskMounter.FormatAndMount(devicePath, deviceMountPath, volSourceFSType, options)
}

View File

@@ -23,6 +23,7 @@ import (
"k8s.io/klog/v2"
"k8s.io/mount-utils"
utilexec "k8s.io/utils/exec"
"k8s.io/utils/keymutex"
v1 "k8s.io/api/core/v1"
@@ -126,7 +127,7 @@ func (attacher *iscsiAttacher) MountDevice(spec *volume.Spec, devicePath string,
options = volumeutil.AddSELinuxMountOption(options, mountArgs.SELinuxLabel)
}
if notMnt {
diskMounter := &mount.SafeFormatAndMount{Interface: mounter, Exec: attacher.host.GetExec()}
diskMounter := &mount.SafeFormatAndMount{Interface: mounter, Exec: utilexec.New()}
mountOptions := volumeutil.MountOptionFromSpec(spec, options...)
err = diskMounter.FormatAndMount(devicePath, deviceMountPath, fsType, mountOptions)
if err != nil {
@@ -211,7 +212,7 @@ func volumeSpecToMounter(spec *volume.Spec, host volume.VolumeHost, targetLocks
if err != nil {
return nil, err
}
exec := host.GetExec()
exec := utilexec.New()
volumeMode, err := volumeutil.GetVolumeMode(spec)
if err != nil {
@@ -231,13 +232,12 @@ func volumeSpecToMounter(spec *volume.Spec, host volume.VolumeHost, targetLocks
}
func volumeSpecToUnmounter(mounter mount.Interface, host volume.VolumeHost, plugin *iscsiPlugin) *iscsiDiskUnmounter {
exec := host.GetExec()
return &iscsiDiskUnmounter{
iscsiDisk: &iscsiDisk{
plugin: plugin,
},
mounter: mounter,
exec: exec,
exec: utilexec.New(),
deviceUtil: volumeutil.NewDeviceHandler(volumeutil.NewIOHandler()),
}
}

View File

@@ -109,7 +109,7 @@ func (plugin *iscsiPlugin) NewMounter(spec *volume.Spec, pod *v1.Pod) (volume.Mo
if err != nil {
return nil, err
}
return plugin.newMounterInternal(spec, pod.UID, &ISCSIUtil{}, plugin.host.GetMounter(), plugin.host.GetExec(), secret)
return plugin.newMounterInternal(spec, pod.UID, &ISCSIUtil{}, plugin.host.GetMounter(), utilexec.New(), secret)
}
func (plugin *iscsiPlugin) newMounterInternal(spec *volume.Spec, podUID types.UID, manager diskManager, mounter mount.Interface, exec utilexec.Interface, secret map[string]string) (volume.Mounter, error) {
@@ -152,7 +152,7 @@ func (plugin *iscsiPlugin) NewBlockVolumeMapper(spec *volume.Spec, pod *v1.Pod)
return nil, err
}
}
return plugin.newBlockVolumeMapperInternal(spec, uid, &ISCSIUtil{}, plugin.host.GetMounter(), plugin.host.GetExec(), secret)
return plugin.newBlockVolumeMapperInternal(spec, uid, &ISCSIUtil{}, plugin.host.GetMounter(), utilexec.New(), secret)
}
func (plugin *iscsiPlugin) newBlockVolumeMapperInternal(spec *volume.Spec, podUID types.UID, manager diskManager, mounter mount.Interface, exec utilexec.Interface, secret map[string]string) (volume.BlockVolumeMapper, error) {
@@ -181,7 +181,7 @@ func (plugin *iscsiPlugin) newBlockVolumeMapperInternal(spec *volume.Spec, podUI
}
func (plugin *iscsiPlugin) NewUnmounter(volName string, podUID types.UID) (volume.Unmounter, error) {
return plugin.newUnmounterInternal(volName, podUID, &ISCSIUtil{}, plugin.host.GetMounter(), plugin.host.GetExec())
return plugin.newUnmounterInternal(volName, podUID, &ISCSIUtil{}, plugin.host.GetMounter(), utilexec.New())
}
func (plugin *iscsiPlugin) newUnmounterInternal(volName string, podUID types.UID, manager diskManager, mounter mount.Interface, exec utilexec.Interface) (volume.Unmounter, error) {
@@ -201,7 +201,7 @@ func (plugin *iscsiPlugin) newUnmounterInternal(volName string, podUID types.UID
// NewBlockVolumeUnmapper creates a new volume.BlockVolumeUnmapper from recoverable state.
func (plugin *iscsiPlugin) NewBlockVolumeUnmapper(volName string, podUID types.UID) (volume.BlockVolumeUnmapper, error) {
return plugin.newUnmapperInternal(volName, podUID, &ISCSIUtil{}, plugin.host.GetExec())
return plugin.newUnmapperInternal(volName, podUID, &ISCSIUtil{}, utilexec.New())
}
func (plugin *iscsiPlugin) newUnmapperInternal(volName string, podUID types.UID, manager diskManager, exec utilexec.Interface) (volume.BlockVolumeUnmapper, error) {

View File

@@ -35,6 +35,7 @@ import (
"k8s.io/kubernetes/pkg/volume/util/hostutil"
"k8s.io/kubernetes/pkg/volume/validation"
"k8s.io/mount-utils"
utilexec "k8s.io/utils/exec"
"k8s.io/utils/keymutex"
utilstrings "k8s.io/utils/strings"
)
@@ -309,9 +310,13 @@ func (plugin *localVolumePlugin) NewDeviceMounter() (volume.DeviceMounter, error
if !ok {
return nil, fmt.Errorf("plugin volume host does not implement KubeletVolumeHost interface")
}
return plugin.newDeviceMounterInternal(kvh, plugin.host.GetMounter(), utilexec.New())
}
func (plugin *localVolumePlugin) newDeviceMounterInternal(kvh volume.KubeletVolumeHost, mounter mount.Interface, exec utilexec.Interface) (volume.DeviceMounter, error) {
return &deviceMounter{
plugin: plugin,
mounter: util.NewSafeFormatAndMountFromHost(plugin.host),
mounter: mount.NewSafeFormatAndMount(mounter, exec),
hostUtil: kvh.GetHostUtil(),
}, nil
}
@@ -449,9 +454,13 @@ func (dm *deviceMounter) GetDeviceMountPath(spec *volume.Spec) (string, error) {
}
func (plugin *localVolumePlugin) NewDeviceUnmounter() (volume.DeviceUnmounter, error) {
return plugin.newDeviceUnmounterInternal(plugin.host.GetMounter(), utilexec.New())
}
func (plugin *localVolumePlugin) newDeviceUnmounterInternal(mounter mount.Interface, exec utilexec.Interface) (volume.DeviceUnmounter, error) {
return &deviceMounter{
plugin: plugin,
mounter: util.NewSafeFormatAndMountFromHost(plugin.host),
mounter: mount.NewSafeFormatAndMount(mounter, exec),
}, nil
}

View File

@@ -35,6 +35,7 @@ import (
volumetest "k8s.io/kubernetes/pkg/volume/testing"
"k8s.io/kubernetes/pkg/volume/util/hostutil"
"k8s.io/mount-utils"
testingexec "k8s.io/utils/exec/testing"
)
const (
@@ -135,7 +136,7 @@ func getPersistentPlugin(t *testing.T) (string, volume.PersistentVolumePlugin) {
return tmpDir, plug
}
func getDeviceMountablePluginWithBlockPath(t *testing.T, isBlockDevice bool) (string, volume.DeviceMountableVolumePlugin) {
func getDeviceMountablePluginWithBlockPath(t *testing.T, isBlockDevice bool) (string, *localVolumePlugin) {
var (
source string
err error
@@ -169,7 +170,7 @@ func getDeviceMountablePluginWithBlockPath(t *testing.T, isBlockDevice bool) (st
if plug.GetPluginName() != localVolumePluginName {
t.Errorf("Wrong name: %s", plug.GetPluginName())
}
return source, plug
return source, plug.(*localVolumePlugin)
}
func getTestVolume(readOnly bool, path string, isBlock bool, mountOptions []string) *volume.Spec {
@@ -258,7 +259,7 @@ func TestBlockDeviceGlobalPathAndMountDevice(t *testing.T) {
tmpBlockDir, plug := getDeviceMountablePluginWithBlockPath(t, true)
defer os.RemoveAll(tmpBlockDir)
dm, err := plug.NewDeviceMounter()
dm, err := plug.newDeviceMounterInternal(plug.host.(volume.KubeletVolumeHost), plug.host.GetMounter(), &testingexec.FakeExec{DisableScripts: true})
if err != nil {
t.Errorf("Failed to make a new device mounter: %v", err)
}
@@ -288,7 +289,7 @@ func TestBlockDeviceGlobalPathAndMountDevice(t *testing.T) {
}
}
du, err := plug.NewDeviceUnmounter()
du, err := plug.newDeviceUnmounterInternal(plug.host.GetMounter(), &testingexec.FakeExec{DisableScripts: true})
if err != nil {
t.Fatalf("Create device unmounter error: %v", err)
}
@@ -304,7 +305,7 @@ func TestFSGlobalPathAndMountDevice(t *testing.T) {
tmpFSDir, plug := getDeviceMountablePluginWithBlockPath(t, false)
defer os.RemoveAll(tmpFSDir)
dm, err := plug.NewDeviceMounter()
dm, err := plug.newDeviceMounterInternal(plug.host.(volume.KubeletVolumeHost), plug.host.GetMounter(), &testingexec.FakeExec{DisableScripts: true})
if err != nil {
t.Errorf("Failed to make a new device mounter: %v", err)
}

View File

@@ -25,7 +25,6 @@ import (
"k8s.io/klog/v2"
"k8s.io/mount-utils"
"k8s.io/utils/exec"
authenticationv1 "k8s.io/api/authentication/v1"
v1 "k8s.io/api/core/v1"
@@ -407,9 +406,6 @@ type VolumeHost interface {
DeleteServiceAccountTokenFunc() func(podUID types.UID)
// Returns an interface that should be used to execute any utilities in volume plugins
GetExec() exec.Interface
// Returns the labels on the node
GetNodeLabels() (map[string]string, error)

View File

@@ -24,6 +24,7 @@ import (
"k8s.io/klog/v2"
"k8s.io/mount-utils"
"k8s.io/utils/exec"
utilstrings "k8s.io/utils/strings"
volumeclient "github.com/libopenstorage/openstorage/api/client/volume"
@@ -140,7 +141,7 @@ func (plugin *portworxVolumePlugin) newMounterInternal(spec *volume.Spec, podUID
},
fsType: fsType,
readOnly: readOnly,
diskMounter: util.NewSafeFormatAndMountFromHost(plugin.host)}, nil
diskMounter: mount.NewSafeFormatAndMount(plugin.host.GetMounter(), exec.New())}, nil
}
func (plugin *portworxVolumePlugin) NewUnmounter(volName string, podUID types.UID) (volume.Unmounter, error) {

View File

@@ -45,8 +45,6 @@ import (
"k8s.io/kubernetes/pkg/volume/util/hostutil"
"k8s.io/kubernetes/pkg/volume/util/subpath"
"k8s.io/mount-utils"
"k8s.io/utils/exec"
testingexec "k8s.io/utils/exec/testing"
)
type FakeVolumeHost interface {
@@ -63,7 +61,6 @@ type fakeVolumeHost struct {
pluginMgr *VolumePluginMgr
mounter mount.Interface
hostUtil hostutil.HostUtils
exec *testingexec.FakeExec
nodeLabels map[string]string
nodeName string
subpather subpath.Interface
@@ -94,7 +91,6 @@ func newFakeVolumeHost(t *testing.T, rootDir string, kubeClient clientset.Interf
host := &fakeVolumeHost{rootDir: rootDir, kubeClient: kubeClient, nodeName: nodeName, csiDriverLister: driverLister, volumeAttachmentLister: volumeAttachLister}
host.mounter = mount.NewFakeMounter(nil)
host.hostUtil = hostutil.NewFakeHostUtil(pathToTypeMap)
host.exec = &testingexec.FakeExec{DisableScripts: true}
host.pluginMgr = &VolumePluginMgr{}
if err := host.pluginMgr.InitPlugins(plugins, nil /* prober */, host); err != nil {
t.Fatalf("Failed to init plugins while creating fake volume host: %v", err)
@@ -198,10 +194,6 @@ func (f *fakeVolumeHost) GetSecretFunc() func(namespace, name string) (*v1.Secre
}
}
func (f *fakeVolumeHost) GetExec() exec.Interface {
return f.exec
}
func (f *fakeVolumeHost) GetConfigMapFunc() func(namespace, name string) (*v1.ConfigMap, error) {
return func(namespace, name string) (*v1.ConfigMap, error) {
return f.kubeClient.CoreV1().ConfigMaps(namespace).Get(context.TODO(), name, metav1.GetOptions{})
@@ -233,10 +225,6 @@ func (f *fakeVolumeHost) GetEventRecorder() record.EventRecorder {
return nil
}
func (f *fakeVolumeHost) ScriptCommands(scripts []CommandScript) {
ScriptCommands(f.exec, scripts)
}
func (f *fakeVolumeHost) WaitForKubeletErrNil() error {
return wait.PollImmediate(10*time.Millisecond, 10*time.Second, func() (bool, error) {
f.mux.Lock()
@@ -265,7 +253,6 @@ func newFakeAttachDetachVolumeHost(t *testing.T, rootDir string, kubeClient clie
host.volumeAttachmentLister = volumeAttachLister
host.mounter = mount.NewFakeMounter(nil)
host.hostUtil = hostutil.NewFakeHostUtil(pathToTypeMap)
host.exec = &testingexec.FakeExec{DisableScripts: true}
host.pluginMgr = &VolumePluginMgr{}
if err := host.pluginMgr.InitPlugins(plugins, nil /* prober */, host); err != nil {
t.Fatalf("Failed to init plugins while creating fake volume host: %v", err)
@@ -344,7 +331,6 @@ func newFakeKubeletVolumeHost(t *testing.T, rootDir string, kubeClient clientset
host.volumeAttachmentLister = volumeAttachLister
host.mounter = mount.NewFakeMounter(nil)
host.hostUtil = hostutil.NewFakeHostUtil(pathToTypeMap)
host.exec = &testingexec.FakeExec{DisableScripts: true}
host.pluginMgr = &VolumePluginMgr{}
if err := host.pluginMgr.InitPlugins(plugins, nil /* prober */, host); err != nil {
t.Fatalf("Failed to init plugins while creating fake volume host: %v", err)

View File

@@ -34,6 +34,7 @@ import (
"k8s.io/kubernetes/pkg/volume"
volumetypes "k8s.io/kubernetes/pkg/volume/util/types"
"k8s.io/mount-utils"
"k8s.io/utils/exec"
)
var (
@@ -457,6 +458,6 @@ func mergeStorageAllocatedResources(pvc *v1.PersistentVolumeClaim, size resource
// GenericResizeFS : call generic filesystem resizer for plugins that don't have any special filesystem resize requirements
func GenericResizeFS(host volume.VolumeHost, devicePath, deviceMountPath string) (bool, error) {
resizer := mount.NewResizeFs(host.GetExec())
resizer := mount.NewResizeFs(exec.New())
return resizer.Resize(devicePath, deviceMountPath)
}

View File

@@ -333,12 +333,6 @@ func SplitUniqueName(uniqueName v1.UniqueVolumeName) (string, string, error) {
return pluginName, components[2], nil
}
// NewSafeFormatAndMountFromHost creates a new SafeFormatAndMount with Mounter
// and Exec taken from given VolumeHost.
func NewSafeFormatAndMountFromHost(host volume.VolumeHost) *mount.SafeFormatAndMount {
return &mount.SafeFormatAndMount{Interface: host.GetMounter(), Exec: host.GetExec()}
}
// GetVolumeMode retrieves VolumeMode from pv.
// If the volume doesn't have PersistentVolume, it's an inline volume,
// should return volumeMode as filesystem to keep existing behavior.