mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-18 16:21:13 +00:00
Use nsenter on PATH in container, and separate args
nsenter needs '--' to separate calls
This commit is contained in:
parent
91589143a3
commit
fa7000a5bc
@ -54,7 +54,7 @@ var _ = Interface(&NsenterMounter{})
|
|||||||
const (
|
const (
|
||||||
hostRootFsPath = "/rootfs"
|
hostRootFsPath = "/rootfs"
|
||||||
hostProcMountsPath = "/rootfs/proc/mounts"
|
hostProcMountsPath = "/rootfs/proc/mounts"
|
||||||
nsenterPath = "/nsenter"
|
nsenterPath = "nsenter"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Mount runs mount(8) in the host's root mount namespace. Aside from this
|
// Mount runs mount(8) in the host's root mount namespace. Aside from this
|
||||||
@ -94,6 +94,7 @@ func doNsenterMount(source, target, fstype string, options []string) error {
|
|||||||
func makeNsenterArgs(source, target, fstype string, options []string) []string {
|
func makeNsenterArgs(source, target, fstype string, options []string) []string {
|
||||||
nsenterArgs := []string{
|
nsenterArgs := []string{
|
||||||
"--mount=/rootfs/proc/1/ns/mnt",
|
"--mount=/rootfs/proc/1/ns/mnt",
|
||||||
|
"--",
|
||||||
"/usr/bin/mount",
|
"/usr/bin/mount",
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,6 +107,7 @@ func makeNsenterArgs(source, target, fstype string, options []string) []string {
|
|||||||
func (*NsenterMounter) Unmount(target string) error {
|
func (*NsenterMounter) Unmount(target string) error {
|
||||||
args := []string{
|
args := []string{
|
||||||
"--mount=/rootfs/proc/1/ns/mnt",
|
"--mount=/rootfs/proc/1/ns/mnt",
|
||||||
|
"--",
|
||||||
"/usr/bin/umount",
|
"/usr/bin/umount",
|
||||||
target,
|
target,
|
||||||
}
|
}
|
||||||
@ -133,7 +135,7 @@ func (*NsenterMounter) IsMountPoint(file string) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
args := []string{"--mount=/rootfs/proc/1/ns/mnt", "/usr/bin/findmnt", "-o", "target", "--noheadings", "--target", file}
|
args := []string{"--mount=/rootfs/proc/1/ns/mnt", "--", "/usr/bin/findmnt", "-o", "target", "--noheadings", "--target", file}
|
||||||
glog.V(5).Infof("findmnt command: %v %v", nsenterPath, args)
|
glog.V(5).Infof("findmnt command: %v %v", nsenterPath, args)
|
||||||
|
|
||||||
exec := exec.New()
|
exec := exec.New()
|
||||||
|
Loading…
Reference in New Issue
Block a user