mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 15:02:45 +00:00
Merge pull request #123 from sboeuf/fix_k8s
virtcontainers: Don't ignore container mounts based on their path
This commit is contained in:
commit
c4f922dc2c
@ -300,7 +300,7 @@ func (c *Container) createContainersDirs() error {
|
|||||||
func (c *Container) mountSharedDirMounts(hostSharedDir, guestSharedDir string) ([]Mount, error) {
|
func (c *Container) mountSharedDirMounts(hostSharedDir, guestSharedDir string) ([]Mount, error) {
|
||||||
var sharedDirMounts []Mount
|
var sharedDirMounts []Mount
|
||||||
for idx, m := range c.mounts {
|
for idx, m := range c.mounts {
|
||||||
if isSystemMount(m.Destination) || m.Type != "bind" {
|
if m.Type != "bind" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,8 +570,6 @@ func constraintGRPCSpec(grpcSpec *grpc.Spec) {
|
|||||||
grpcSpec.Mounts[idx].Type = "tmpfs"
|
grpcSpec.Mounts[idx].Type = "tmpfs"
|
||||||
grpcSpec.Mounts[idx].Source = "shm"
|
grpcSpec.Mounts[idx].Source = "shm"
|
||||||
grpcSpec.Mounts[idx].Options = []string{"noexec", "nosuid", "nodev", "mode=1777", "size=65536k"}
|
grpcSpec.Mounts[idx].Options = []string{"noexec", "nosuid", "nodev", "mode=1777", "size=65536k"}
|
||||||
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,18 +29,6 @@ import (
|
|||||||
|
|
||||||
var rootfsDir = "rootfs"
|
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 {
|
func major(dev uint64) int {
|
||||||
return int((dev >> 8) & 0xfff)
|
return int((dev >> 8) & 0xfff)
|
||||||
}
|
}
|
||||||
|
@ -29,30 +29,6 @@ import (
|
|||||||
"testing"
|
"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) {
|
func TestMajorMinorNumber(t *testing.T) {
|
||||||
devices := []string{"/dev/zero", "/dev/net/tun"}
|
devices := []string{"/dev/zero", "/dev/net/tun"}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user