Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to run TestGetMounts in chroot #17

Closed
zhsj opened this issue Jun 23, 2020 · 2 comments · Fixed by #18
Closed

Failed to run TestGetMounts in chroot #17

zhsj opened this issue Jun 23, 2020 · 2 comments · Fixed by #18

Comments

@zhsj
Copy link
Contributor

zhsj commented Jun 23, 2020

Background:

I packaged this library in Debian[1], and Ubuntu synced it to its archive[2]. But I found in Ubuntu it failed to build. After inspecting the log[3], I think the reason is TestGetMounts.

TestGetMounts: mountinfo_test.go:22: / should be mounted at least

Ubuntu builds this library with chroot. So I test it in a chroot and add some logs.

    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:722, Parent:27, Major:0, Minor:5, Root:"/", Mountpoint:"/proc", Opts:"rw,relatime", Optional:"shared:177", Fstype:"proc", Source:"proc", VfsOpts:"rw"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:738, Parent:27, Major:0, Minor:20, Root:"/", Mountpoint:"/sys", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:7", Fstype:"sysfs", Source:"sysfs", VfsOpts:"rw"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:739, Parent:738, Major:0, Minor:7, Root:"/", Mountpoint:"/sys/kernel/security", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:8", Fstype:"securityfs", Source:"securityfs", VfsOpts:"rw"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:740, Parent:738, Major:0, Minor:25, Root:"/", Mountpoint:"/sys/fs/cgroup", Opts:"ro,nosuid,nodev,noexec", Optional:"shared:9", Fstype:"tmpfs", Source:"tmpfs", VfsOpts:"ro,mode=755"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:741, Parent:740, Major:0, Minor:26, Root:"/", Mountpoint:"/sys/fs/cgroup/unified", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:10", Fstype:"cgroup2", Source:"cgroup2", VfsOpts:"rw,nsdelegate"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:742, Parent:740, Major:0, Minor:27, Root:"/", Mountpoint:"/sys/fs/cgroup/systemd", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:11", Fstype:"cgroup", Source:"cgroup", VfsOpts:"rw,xattr,name=systemd"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:743, Parent:740, Major:0, Minor:30, Root:"/", Mountpoint:"/sys/fs/cgroup/memory", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:15", Fstype:"cgroup", Source:"cgroup", VfsOpts:"rw,memory"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:802, Parent:740, Major:0, Minor:31, Root:"/", Mountpoint:"/sys/fs/cgroup/cpuset", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:16", Fstype:"cgroup", Source:"cgroup", VfsOpts:"rw,cpuset"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:813, Parent:740, Major:0, Minor:32, Root:"/", Mountpoint:"/sys/fs/cgroup/net_cls,net_prio", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:17", Fstype:"cgroup", Source:"cgroup", VfsOpts:"rw,net_cls,net_prio"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:814, Parent:740, Major:0, Minor:33, Root:"/", Mountpoint:"/sys/fs/cgroup/perf_event", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:18", Fstype:"cgroup", Source:"cgroup", VfsOpts:"rw,perf_event"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:815, Parent:740, Major:0, Minor:34, Root:"/", Mountpoint:"/sys/fs/cgroup/devices", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:19", Fstype:"cgroup", Source:"cgroup", VfsOpts:"rw,devices"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:816, Parent:740, Major:0, Minor:35, Root:"/", Mountpoint:"/sys/fs/cgroup/blkio", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:20", Fstype:"cgroup", Source:"cgroup", VfsOpts:"rw,blkio"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:817, Parent:740, Major:0, Minor:36, Root:"/", Mountpoint:"/sys/fs/cgroup/cpu,cpuacct", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:21", Fstype:"cgroup", Source:"cgroup", VfsOpts:"rw,cpu,cpuacct"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:818, Parent:740, Major:0, Minor:37, Root:"/", Mountpoint:"/sys/fs/cgroup/rdma", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:22", Fstype:"cgroup", Source:"cgroup", VfsOpts:"rw,rdma"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:819, Parent:740, Major:0, Minor:38, Root:"/", Mountpoint:"/sys/fs/cgroup/freezer", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:23", Fstype:"cgroup", Source:"cgroup", VfsOpts:"rw,freezer"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:820, Parent:740, Major:0, Minor:39, Root:"/", Mountpoint:"/sys/fs/cgroup/pids", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:24", Fstype:"cgroup", Source:"cgroup", VfsOpts:"rw,pids"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:822, Parent:738, Major:0, Minor:28, Root:"/", Mountpoint:"/sys/fs/pstore", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:12", Fstype:"pstore", Source:"pstore", VfsOpts:"rw"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:823, Parent:738, Major:0, Minor:29, Root:"/", Mountpoint:"/sys/fs/bpf", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:13", Fstype:"bpf", Source:"none", VfsOpts:"rw,mode=700"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:824, Parent:738, Major:0, Minor:8, Root:"/", Mountpoint:"/sys/kernel/debug", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:26", Fstype:"debugfs", Source:"debugfs", VfsOpts:"rw"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:825, Parent:738, Major:0, Minor:12, Root:"/", Mountpoint:"/sys/kernel/tracing", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:28", Fstype:"tracefs", Source:"tracefs", VfsOpts:"rw"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:1189, Parent:27, Major:0, Minor:6, Root:"/", Mountpoint:"/dev", Opts:"rw,nosuid,noexec,relatime", Optional:"shared:2", Fstype:"devtmpfs", Source:"udev", VfsOpts:"rw,size=12242392k,nr_inodes=3060598,mode=755"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:1191, Parent:1189, Major:0, Minor:21, Root:"/", Mountpoint:"/dev/pts", Opts:"rw,nosuid,noexec,relatime", Optional:"shared:3", Fstype:"devpts", Source:"devpts", VfsOpts:"rw,gid=5,mode=620,ptmxmode=000"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:1192, Parent:1189, Major:0, Minor:23, Root:"/", Mountpoint:"/dev/shm", Opts:"rw,nosuid,nodev", Optional:"shared:4", Fstype:"tmpfs", Source:"tmpfs", VfsOpts:"rw"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:1193, Parent:1189, Major:0, Minor:41, Root:"/", Mountpoint:"/dev/hugepages", Opts:"rw,relatime", Optional:"shared:27", Fstype:"hugetlbfs", Source:"hugetlbfs", VfsOpts:"rw,pagesize=2M"}
    TestGetMounts: mountinfo_test.go:15: &mountinfo.Info{ID:1194, Parent:1189, Major:0, Minor:19, Root:"/", Mountpoint:"/dev/mqueue", Opts:"rw,nosuid,nodev,noexec,relatime", Optional:"shared:29", Fstype:"mqueue", Source:"mqueue", VfsOpts:"rw"}
    TestGetMounts: mountinfo_test.go:22: / should be mounted at least

Since this test reads /proc/self/mountinfo, change the test from / to /proc is much better.

[1] https://tracker.debian.org/pkg/golang-github-moby-sys
[2] https://launchpad.net/ubuntu/+source/golang-github-moby-sys
[3] https://launchpadlibrarian.net/482039299/buildlog_ubuntu-groovy-amd64.golang-github-moby-sys_0.0~git20200518.0783079-1_BUILDING.txt.gz

kolyshkin added a commit to kolyshkin/sys that referenced this issue Jun 24, 2020
Apparently, Ubuntu build system is some sort of a chroot which does not
have / mount in its /proc/self/mountinfo. This leads to test failure
described in moby#17.

The fix is not to require a specific mount (even '/' that must exist but
apparently does not in some setups). Instead, let's require at least 2
mounts, doesn't matter which ones.

For reference, his test case was added by
moby/moby#4812

Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin
Copy link
Collaborator

This test was added by PR
moby/moby#4812 (commit (moby/moby@a7e181c).

kolyshkin added a commit to kolyshkin/sys that referenced this issue Jun 24, 2020
Apparently, Ubuntu build system is some sort of a chroot which does not
have / mount in its /proc/self/mountinfo. This leads to test failure
described in moby#17.

The fix is not to require a specific mount (even '/' that must exist but
apparently does not in some setups). Instead, let's require at least 2
mounts, doesn't matter which ones.

For reference, his test case was added by
moby/moby#4812

Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin
Copy link
Collaborator

The Linux kernel's show_mountinfo() has a check that the mount is accessible, and it is not shown if not. Looks like this is why the mount for / is not shown in the Ubuntu case -- they have some weird setup.

Nevertheless, a proposed fix is #18.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants