Skip to content

tests: run test_mounts.py in the CI, fix what it finds - #2393

Merged
giuseppe merged 8 commits into
containers:mainfrom
kolyshkin:test-mounts-ci
Oct 21, 2026
Merged

giuseppe merged 8 commits into
containers:mainfrom
kolyshkin:test-mounts-ci

Conversation

@kolyshkin

@kolyshkin kolyshkin commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

tests/test_mounts.py is skipped as a whole when the libmount python module is not available, which is the case on the Ubuntu runners, so none of the mount tests runs in the CI. This makes the import lazy, so that only the 15 tests needing it are skipped, and fixes what was broken meanwhile:

  • tests/init: check-feature idmapped-mounts could leave its child paused forever if the parent exited before the child set PR_SET_PDEATHSIG; holding stdout, it made the test run hang.
  • linux: crun mounts add created a missing destination as the root user of the host, which fails with EOVERFLOW in a file system owned by the user namespace of the container (e.g. a tmpfs). The destinations are now created by the root user of the container.
  • tests: mount-add-mounts-container-namespaces, mount-add-mounts-nested-userns-mountns and mount-add-mounts-nested-userns could not start the container with userns (rootfs not accessible to the mapped root), and the latter used crun exec into a user namespace without mappings.
  • tests: mount-propagation-shared fails on kernel 6.12 (CentOS Stream 10), and likely on the Ubuntu runners as well; it is skipped when the mount is not shared at all, see rshared bind mount loses the peer group of its source on kernel 6.12 #2392.
  • tests: the mounts add/remove tests are skipped where openat2 is not available, as in check-no-openat2.
  • tests: mount-overlay-fs created the overlay layers in /tmp, which is on overlayfs when the tests run in a container (found by centos10-build).

Tested on Fedora 45 (kernel 7.3) and CentOS Stream 10 (kernel 6.12), as root (cgroupfs and systemd), rootless, with unshare -r and with tests/no_openat2: all of test_mounts.py passes, with or without the libmount module (with tests/no_openat2, the mounts add/remove tests are skipped).

check_idmapped_mounts() relies on PR_SET_PDEATHSIG to get rid of the
child it creates, but the child sets it only after clone() returns, by
which time the parent may already be gone, leaving the child paused
forever.  As it inherits stdout and stderr, whatever reads them waits
for it as well, and a test run hangs.

Exit the child if its parent changed after setting PR_SET_PDEATHSIG.

Assisted-by: Claude Code (claude-opus-5-5)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin

Copy link
Copy Markdown
Collaborator Author

Regarding "linux: do not require openat2 in mounts add/remove" commit -- I don't like it that much. The alternative is to require openat2 (which is the case before this PR), and just guard the tests. Let me know what you think @giuseppe

@giuseppe giuseppe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Since commit 7d7b81f ("linux: do not follow symlinks in `mounts
remove`"), both `mounts add` and `mounts remove` require openat2 with
RESOLVE_NO_SYMLINKS, and fail with ENOSYS where it is not available,
which is what check-no-openat2 emulates:

  open `/foo/bar`: Function not implemented

Add `check-feature openat2` to tests/init, and skip the tests using
`mounts add` or `mounts remove` where openat2 does not work.

Assisted-by: Claude Code (claude-opus-5-5)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
do_mount_in_a_container() joins only the mount namespace of the
container, so a missing destination is created by the root user of the
host.  When it is in a file system owned by the user namespace of the
container, e.g. a tmpfs, where the root user of the host has no
mapping, mkdir fails with EOVERFLOW:

  mkdir `/foo/tmpfs`: Value too large for defined data type

Create the missing destinations first, from a process that also joined
the user namespace of the container and switched to its root user, as
the container itself would.  The mounts are still moved in place by the
root user of the host.

Assisted-by: Claude Code (claude-opus-5-5)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
test_add_mounts_container_namespaces and helper_add_mounts_nested_userns
map the root user of the container to the host uid 1, but create the
rootfs in a directory only the host root can access, so the container
fails to start:

  open `rootfs`: Permission denied

Chown the rootfs to the user the container root is mapped to, as the
other tests using this mapping do.

Assisted-by: Claude Code (claude-opus-5-5)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
In helper_add_mounts_nested_userns, the container process moves to a
new user namespace without any mapping, and `crun exec` joins it, so
the check of the added mounts fails:

  setgroups: Operation not permitted

Read the mounts of the container process from the host instead.

Assisted-by: Claude Code (claude-opus-5-5)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
mount-overlay-fs creates the lower, upper and work directories with
tempfile.mkdtemp(), that is in /tmp.  When the tests run in a container,
as in the centos10-build CI job, /tmp is on overlayfs, which is not
supported as upperdir, and the container fails to start:

  overlay: filesystem on .../upper not supported as upperdir

Create them under the tests root, as other tests in this file do.

Assisted-by: Claude Code (claude-opus-5-5)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
The rshared bind mount loses the peer group of its source on some
kernels, e.g. 6.12 on CentOS Stream 10, see
containers#2392.  Skip the test
when the mount is not shared at all, until it is fixed.

Assisted-by: Claude Code (claude-opus-5-5)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
The whole file is skipped if the libmount python module is not
available, which is the case on the Ubuntu runners of the CI, so none
of the mount tests is run there.

Import it only where it is used, and skip only the tests that need it.

Assisted-by: Claude Code (claude-opus-5-5)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@giuseppe
giuseppe merged commit 1dd925a into containers:main Oct 21, 2026
66 checks passed
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 this pull request may close these issues.

2 participants