mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
tests/int: add "runc exec [init changes cgroup]"
Add a test case to reproduce runc issue 5089. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -321,6 +321,41 @@ function check_exec_debug() {
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
# https://github.com/opencontainers/runc/issues/5089
|
||||
@test "runc exec [init changes cgroup]" {
|
||||
requires root cgroups_v2
|
||||
|
||||
NEW_CGROUP_REL=/runc-tst-$$
|
||||
NEW_CGROUP=/sys/fs/cgroup$NEW_CGROUP_REL
|
||||
mkdir $NEW_CGROUP
|
||||
|
||||
# The container is placed into a $CGROUP_V2_PATH cgroup.
|
||||
set_cgroups_path
|
||||
# And upon the start it moves itself into $NEW_CGROUP.
|
||||
set_cgroup_mount_writable
|
||||
update_config ' .linux.namespaces -= [{"type": "cgroup"}]
|
||||
| .process.args = ["sh", "-c", "echo 1 > '$NEW_CGROUP'/cgroup.procs && exec sleep 1h"]'
|
||||
|
||||
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
|
||||
[ $status -eq 0 ]
|
||||
testcontainer test_busybox running
|
||||
sleep 1
|
||||
# Remove the original container cgroup. If systemd cgroup manager is used by runc,
|
||||
# the cgroup might have already be deleted by systemd, so we ignore rmdir errors.
|
||||
rmdir "$CGROUP_V2_PATH" || true
|
||||
test -d "$CGROUP_V2_PATH" && false
|
||||
|
||||
# Test that runc exec is able to fallback to container's init cgroup
|
||||
# even if the original cgroup is gone.
|
||||
runc exec test_busybox cat /proc/self/cgroup
|
||||
[ $status -eq 0 ]
|
||||
[ "$output" = "0::$NEW_CGROUP_REL" ]
|
||||
|
||||
# Cleanup.
|
||||
runc delete -f test_busybox
|
||||
rmdir "$NEW_CGROUP"
|
||||
}
|
||||
|
||||
@test "runc exec [execve error]" {
|
||||
cat <<EOF >rootfs/run.sh
|
||||
#!/mmnnttbb foo bar
|
||||
|
||||
Reference in New Issue
Block a user