Merge pull request #123 from sboeuf/fix_k8s

virtcontainers: Don't ignore container mounts based on their path
This commit is contained in:
Salvador Fuentes 2018-03-28 13:20:11 -06:00 committed by GitHub
commit c4f922dc2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1 additions and 39 deletions

View File

@ -300,7 +300,7 @@ func (c *Container) createContainersDirs() error {
func (c *Container) mountSharedDirMounts(hostSharedDir, guestSharedDir string) ([]Mount, error) {
var sharedDirMounts []Mount
for idx, m := range c.mounts {
if isSystemMount(m.Destination) || m.Type != "bind" {
if m.Type != "bind" {
continue
}

View File

@ -570,8 +570,6 @@ func constraintGRPCSpec(grpcSpec *grpc.Spec) {
grpcSpec.Mounts[idx].Type = "tmpfs"
grpcSpec.Mounts[idx].Source = "shm"
grpcSpec.Mounts[idx].Options = []string{"noexec", "nosuid", "nodev", "mode=1777", "size=65536k"}
break
}
}
}

View File

@ -29,18 +29,6 @@ import (
var rootfsDir = "rootfs"
var systemMountPrefixes = []string{"/proc", "/dev", "/sys"}
func isSystemMount(m string) bool {
for _, p := range systemMountPrefixes {
if m == p || strings.HasPrefix(m, p+"/") {
return true
}
}
return false
}
func major(dev uint64) int {
return int((dev >> 8) & 0xfff)
}

View File

@ -29,30 +29,6 @@ import (
"testing"
)
func TestIsSystemMount(t *testing.T) {
tests := []struct {
mnt string
expected bool
}{
{"/sys", true},
{"/sys/", true},
{"/sys//", true},
{"/sys/fs", true},
{"/sys/fs/", true},
{"/sys/fs/cgroup", true},
{"/sysfoo", false},
{"/home", false},
{"/dev/block/", true},
}
for _, test := range tests {
result := isSystemMount(test.mnt)
if result != test.expected {
t.Fatalf("Expected result for path %s : %v, got %v", test.mnt, test.expected, result)
}
}
}
func TestMajorMinorNumber(t *testing.T) {
devices := []string{"/dev/zero", "/dev/net/tun"}