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

Fix running tests under Docker/Podman and cgroup v2 #3960

Merged
merged 4 commits into from
Aug 3, 2023

Conversation

kolyshkin
Copy link
Contributor

For "make integration", the tests are run inside a Docker/Podman container. Problem is, if cgroup v2 is used, the in-container /sys/fs/cgroup/cgroup.subtree_control is empty.

The added script, used as Docker entrypoint, moves the current process into a sub-cgroup, and then adds all controllers in top-level cgroup.subtree_control.

Addresses #3955

@cyphar
Copy link
Member

cyphar commented Aug 3, 2023

Is this a systemd bug, or something else? It seems very strange that --privileged with Delegate=yes doesn't result in a cgroup you can use in a delegated manner...

EDIT: Oh, I finally understand the issue. The no-internal-nodes constraint strikes again...

@kolyshkin
Copy link
Contributor Author

kolyshkin commented Aug 3, 2023

OK, after merging #3954 my make integration works now.

Added two small fixes to unit tests, which assumed systemd is there.

With this, the following passes on my machine (Fedora/Podman):

sudo make integration
sudo make unittest

Note that the above do not test runc systemd cgroup driver; for that, I usually run sudo make localintegration RUNC_USE_SYSTEMD=yes

@kolyshkin kolyshkin marked this pull request as ready for review August 3, 2023 03:28
@kolyshkin
Copy link
Contributor Author

Added one more commit to fix a flake (not related to cgroup v2 but the fix is easy)

script/prepare-cgroup-v2.sh Outdated Show resolved Hide resolved
For "make integration", the tests are run inside a Docker/Podman
container. Problem is, if cgroup v2 is used, the in-container
/sys/fs/cgroup/cgroup.subtree_control is empty.

The added script, used as Docker entrypoint, moves the current process
into a sub-cgroup, and then adds all controllers in top-level
cgroup.subtree_control.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Split the test into two -- for fs and systemd cgroup managers, and only
run the second one if systemd is available.

Prevents the following failure during `make unittest`:

> === RUN   TestNilResources
>     manager_test.go:27: systemd not running on this host, cannot use systemd cgroups manager
> --- FAIL: TestNilResources (0.22s)

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
A few cases relied on the fact that systemd is used, and thus
/sys/fs/cgroup/user.slice is available.

Guess what, in case of "make unittest" it might not be.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This test fails in CI sometimes with the following error:

> `testcontainer test_update stopped' failed

Give OOM killer some time to do its job.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Contributor Author

@AkihiroSuda PTAL

@AkihiroSuda AkihiroSuda added area/cgroupv2 area/ci backport/1.1-todo A PR in main branch which needs to be backported to release-1.1 labels Aug 3, 2023
@AkihiroSuda AkihiroSuda merged commit 23e41ef into opencontainers:main Aug 3, 2023
@kolyshkin
Copy link
Contributor Author

Backported to 1.1 in #3976.

@kolyshkin kolyshkin added backport/1.1-done A PR in main branch which has been backported to release-1.1 and removed backport/1.1-todo A PR in main branch which needs to be backported to release-1.1 labels Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cgroupv2 area/ci backport/1.1-done A PR in main branch which has been backported to release-1.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants