diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index d099acae2..236f86528 100644 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -103,13 +103,21 @@ function init_cgroup_paths() { if stat -f -c %t /sys/fs/cgroup | grep -qFw 63677270; then CGROUP_UNIFIED=yes + local controllers="/sys/fs/cgroup/cgroup.controllers" + # For rootless + systemd case, controllers delegation is required, + # so check the controllers that the current user has, not the top one. + # NOTE: delegation of cpuset requires systemd >= 244 (Fedora >= 32, Ubuntu >= 20.04). + if [[ "$ROOTLESS" -ne 0 && -n "$RUNC_USE_SYSTEMD" ]]; then + controllers="/sys/fs/cgroup/user.slice/user-$(id -u).slice/user@$(id -u).service/cgroup.controllers" + fi + # "pseudo" controllers do not appear in /sys/fs/cgroup/cgroup.controllers. # - devices (since kernel 4.15) we must assume to be supported because # it's quite hard to test. # - freezer (since kernel 5.2) we can auto-detect by looking for the # "cgroup.freeze" file a *non-root* cgroup. CGROUP_SUBSYSTEMS=$( - cat /sys/fs/cgroup/cgroup.controllers + cat "$controllers" echo devices ) CGROUP_BASE_PATH=/sys/fs/cgroup diff --git a/tests/integration/update.bats b/tests/integration/update.bats index 9e4d702f0..bc9005663 100644 --- a/tests/integration/update.bats +++ b/tests/integration/update.bats @@ -22,15 +22,7 @@ function setup() { # v1 and v2: memory/swap, pids, and cpuset. @test "update cgroup v1/v2 common limits" { [[ "$ROOTLESS" -ne 0 && -z "$RUNC_USE_SYSTEMD" ]] && requires rootless_cgroup - if [[ "$ROOTLESS" -ne 0 && -n "$RUNC_USE_SYSTEMD" ]]; then - file="/sys/fs/cgroup/user.slice/user-$(id -u).slice/user@$(id -u).service/cgroup.controllers" - # NOTE: delegation of cpuset requires systemd >= 244 (Fedora >= 32, Ubuntu >= 20.04). - for f in memory pids cpuset; do - if grep -qwv $f "$file"; then - skip "$f is not enabled in $file" - fi - done - fi + requires cgroups_memory cgroups_pids cgroups_cpuset init_cgroup_paths # run a few busyboxes detached @@ -70,10 +62,6 @@ function setup() { fi # check that initial values were properly set - if [[ "$CGROUP_UNIFIED" = "yes" ]] && ! grep -qw memory "$CGROUP_PATH/cgroup.controllers"; then - # This happen on containerized environment because "echo +memory > /sys/fs/cgroup/cgroup.subtree_control" fails with EINVAL - skip "memory controller not available" - fi check_cgroup_value $MEM_LIMIT 33554432 check_systemd_value $SD_MEM_LIMIT 33554432 @@ -83,7 +71,7 @@ function setup() { check_cgroup_value "pids.max" 20 check_systemd_value "TasksMax" 20 - # update cpuset if supported (i.e. we're running on a multicore cpu) + # update cpuset if possible (i.e. we're running on a multicore cpu) cpu_count=$(grep -c '^processor' /proc/cpuinfo) if [ "$cpu_count" -gt 1 ]; then runc update test_update --cpuset-cpus "1" @@ -426,7 +414,7 @@ EOF @test "update cpuset parameters via resources.CPU" { [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup - requires smp + requires smp cgroups_cpuset local AllowedCPUs='AllowedCPUs' AllowedMemoryNodes='AllowedMemoryNodes' # these properties require systemd >= v244 @@ -482,7 +470,7 @@ EOF @test "update cpuset parameters via v2 unified map" { # This test assumes systemd >= v244 [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup - requires cgroups_v2 smp + requires cgroups_v2 smp cgroups_cpuset update_config ' .linux.resources.unified |= { "cpuset.cpus": "0",