Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tests/integration/exec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading