Merge pull request #2586 from hakman/fix-imagef-detection

Fix incorrect detection of images path
This commit is contained in:
David Ashpole 2020-06-15 10:00:51 -07:00 committed by GitHub
commit 71fa79d18e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -329,7 +329,8 @@ func (i *RealFsInfo) updateContainerImagesPath(label string, mounts []mount.Moun
for _, m := range mounts {
if _, ok := containerImagePaths[m.MountPoint]; ok {
if useMount == nil || (len(useMount.MountPoint) < len(m.MountPoint)) {
useMount = &m
useMount = new(mount.MountInfo)
*useMount = m
}
}
}

View File

@ -360,6 +360,22 @@ func TestAddDockerImagesLabel(t *testing.T) {
expectedDockerDevice string
expectedPartition *partition
}{
{
name: "single partition, no dedicated image fs",
mounts: []mount.MountInfo{
{
Source: "/dev/root",
MountPoint: "/",
FsType: "ext4",
},
{
Source: "/sys/fs/cgroup",
MountPoint: "/sys/fs/cgroup",
FsType: "tmpfs",
},
},
expectedDockerDevice: "/dev/root",
},
{
name: "devicemapper, not loopback",
driver: "devicemapper",