mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-15 14:43:51 +00:00
mounts: Add check for system volumes
We handle system directories differently, if its a bind mount we mount the guest system directory to the container mount and skip the 9p share mount. However, we should not do this for docker volumes which are directories created by Docker. This introduces a Docker specific check, but that is the only information available to us at the OCI layer. Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
parent
814e5de224
commit
70c193132d
@ -477,7 +477,11 @@ func (c *Container) mountSharedDirMounts(hostSharedDir, guestSharedDir string) (
|
||||
var sharedDirMounts []Mount
|
||||
var ignoredMounts []Mount
|
||||
for idx, m := range c.mounts {
|
||||
if isSystemMount(m.Destination) || m.Type != "bind" {
|
||||
if isSystemMount(m.Destination) && !IsDockerVolume(m.Source) {
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Type != "bind" {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -326,3 +326,19 @@ func bindUnmountAllRootfs(ctx context.Context, sharedDir string, sandbox *Sandbo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
dockerVolumePrefix = "/var/lib/docker/volumes"
|
||||
dockerVolumeSuffix = "_data"
|
||||
)
|
||||
|
||||
// IsDockerVolume returns true if the given source path is
|
||||
// a docker volume.
|
||||
// This uses a very specific path that is used by docker.
|
||||
func IsDockerVolume(path string) bool {
|
||||
if strings.HasPrefix(path, dockerVolumePrefix) && filepath.Base(path) == dockerVolumeSuffix {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -282,3 +282,13 @@ func TestIsDeviceMapper(t *testing.T) {
|
||||
t.Fatal()
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsDockerVolume(t *testing.T) {
|
||||
path := "/var/lib/docker/volumes/00da1347c7cf4f15db35f/_data"
|
||||
isDockerVolume := IsDockerVolume(path)
|
||||
assert.True(t, isDockerVolume)
|
||||
|
||||
path = "/var/lib/testdir"
|
||||
isDockerVolume := IsDockerVolume(path)
|
||||
assert.False(t, isDockerVolume)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user