Ensure the mount point is propagated

mount with `rshared`, the host path should be shared.
mount with `rslave`, the host pash should be shared or slave.

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
This commit is contained in:
Yanqiang Miao
2017-09-08 22:58:39 +08:00
parent da31647ef8
commit 49eb38a5d4
5 changed files with 212 additions and 36 deletions

View File

@@ -40,6 +40,7 @@ type OS interface {
WriteFile(filename string, data []byte, perm os.FileMode) error
Mount(source string, target string, fstype string, flags uintptr, data string) error
Unmount(target string, flags int) error
GetMounts() ([]*mount.Info, error)
}
// RealOS is used to dispatch the real system level operations.
@@ -114,3 +115,8 @@ func (RealOS) Unmount(target string, flags int) error {
}
return unix.Unmount(target, flags)
}
// GetMounts retrieves a list of mounts for the current running process.
func (RealOS) GetMounts() ([]*mount.Info, error) {
return mount.GetMounts()
}

View File

@@ -21,6 +21,7 @@ import (
"os"
"sync"
"github.com/docker/docker/pkg/mount"
"golang.org/x/net/context"
osInterface "github.com/kubernetes-incubator/cri-containerd/pkg/os"
@@ -48,6 +49,7 @@ type FakeOS struct {
WriteFileFn func(string, []byte, os.FileMode) error
MountFn func(source string, target string, fstype string, flags uintptr, data string) error
UnmountFn func(target string, flags int) error
GetMountsFn func() ([]*mount.Info, error)
calls []CalledDetail
errors map[string]error
}
@@ -225,3 +227,16 @@ func (f *FakeOS) Unmount(target string, flags int) error {
}
return nil
}
// GetMounts retrieves a list of mounts for the current running process.
func (f *FakeOS) GetMounts() ([]*mount.Info, error) {
f.appendCalls("GetMounts")
if err := f.getError("GetMounts"); err != nil {
return nil, err
}
if f.GetMountsFn != nil {
return f.GetMountsFn()
}
return nil, nil
}