mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 02:09:56 +00:00
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 ```
This commit is contained in:
commit
fd31c3a5cf
@ -21,7 +21,6 @@ go_library(
|
|||||||
"//vendor/k8s.io/api/core/v1:go_default_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/apis/meta/v1:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/types: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/util/strings"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
"k8s.io/kubernetes/pkg/volume/util"
|
"k8s.io/kubernetes/pkg/volume/util"
|
||||||
"k8s.io/utils/exec"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// This is the primary entrypoint for volume plugins.
|
// 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.
|
// to mount the volume are available on the underlying node.
|
||||||
// If not, it returns an error
|
// If not, it returns an error
|
||||||
func (nfsMounter *nfsMounter) CanMount() error {
|
func (nfsMounter *nfsMounter) CanMount() error {
|
||||||
exe := exec.New()
|
exec := nfsMounter.plugin.host.GetExec(nfsMounter.plugin.GetPluginName())
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "linux":
|
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")
|
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 fmt.Errorf("Required binary /sbin/mount.nfs4 is missing")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
case "darwin":
|
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")
|
return fmt.Errorf("Required binary /sbin/mount_nfs is missing")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user