Commit fd31c3a5 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #51110 from jsafrane/exec-nfs

Automatic merge from submit-queue (batch tested with PRs 51105, 51097, 51110, 50843, 51107) nfs: Use VolumeHost.GetExec() to execute stuff in volume plugins **What this PR does / why we need it**: This PR updates nfs volume plugin to use `VolumeHost.GetExec()` to execute utilities like mkfs and lsblk instead of simple `os/exec`. This prepares the volume plugin to run these utilities in containers instead of running them on the host + makes the volume plugin more independent and less hardcoded. See proposal in https://github.com/kubernetes/community/pull/589. Note that this PR does **not** change place where the utilities are executed - `VolumeHost.GetExec()` still leads directly to `os/exec`. It will be changed when the aforementioned proposal is merged and implemented. @kubernetes/sig-storage-pr-reviews **Release note**: ```release-note NONE ```
parents 57b1ea8b 85495bd1
......@@ -21,7 +21,6 @@ go_library(
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/utils/exec:go_default_library",
],
)
......
......@@ -29,7 +29,6 @@ import (
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/utils/exec"
)
// This is the primary entrypoint for volume plugins.
......@@ -192,18 +191,18 @@ func (nfsVolume *nfs) GetPath() string {
// to mount the volume are available on the underlying node.
// If not, it returns an error
func (nfsMounter *nfsMounter) CanMount() error {
exe := exec.New()
exec := nfsMounter.plugin.host.GetExec(nfsMounter.plugin.GetPluginName())
switch runtime.GOOS {
case "linux":
if _, err := exe.Command("/bin/ls", "/sbin/mount.nfs").CombinedOutput(); err != nil {
if _, err := exec.Run("/bin/ls", "/sbin/mount.nfs"); err != nil {
return fmt.Errorf("Required binary /sbin/mount.nfs is missing")
}
if _, err := exe.Command("/bin/ls", "/sbin/mount.nfs4").CombinedOutput(); err != nil {
if _, err := exec.Run("/bin/ls", "/sbin/mount.nfs4"); err != nil {
return fmt.Errorf("Required binary /sbin/mount.nfs4 is missing")
}
return nil
case "darwin":
if _, err := exe.Command("/bin/ls", "/sbin/mount_nfs").CombinedOutput(); err != nil {
if _, err := exec.Run("/bin/ls", "/sbin/mount_nfs"); err != nil {
return fmt.Errorf("Required binary /sbin/mount_nfs is missing")
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment