mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-13 15:14:08 +00:00
virtcontainers: Don't ignore container mounts based on their path
Instead of ignoring containers based on their path, this commit relies on the type of mount being "bind" to choose if this mount should be ignored or not. For instance, we have some use cases where k8s expects the path "/dev/container-log" to be bind mounted inside the container, but the code ignores it because it has the prefix "/dev" which is a system prefix mount. Fixes #122 Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
01f7e46984
commit
08909b2213
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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