File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -270,3 +270,26 @@ function setup() {
270270
271271 check_cpu_weight 42
272272}
273+
274+ @test " runc exec (cgroup v2 hybrid joins correct cgroup)" {
275+ requires root cgroups_hybrid
276+
277+ set_cgroups_path " $BUSYBOX_BUNDLE "
278+ set_cgroup_mount_writable " $BUSYBOX_BUNDLE "
279+
280+ runc run --pid-file pid.txt -d --console-socket " $CONSOLE_SOCKET " test_cgroups_group
281+ [ " $status " -eq 0 ]
282+
283+ pid=$( cat pid.txt)
284+ run_cgroup=$( cat /proc/$pid /cgroup | tail -1)
285+ [[ $run_cgroup == * " runc-cgroups-integration-test" * ]]
286+
287+ runc exec test_cgroups_group cat /proc/self/cgroup
288+ [ " $status " -eq 0 ]
289+
290+ exec_cgroup=${lines[-1]}
291+ [[ $exec_cgroup == * " runc-cgroups-integration-test" * ]]
292+
293+ # check that the cgroups v2 path is the same for both processes
294+ [[ " $run_cgroup " == " $exec_cgroup " ]]
295+ }
Original file line number Diff line number Diff line change @@ -151,6 +151,9 @@ function init_cgroup_paths() {
151151 CGROUP_SUBSYSTEMS+=" freezer"
152152 fi
153153 else
154+ if stat -f -c %t /sys/fs/cgroup/unified | grep -qFw 63677270; then
155+ CGROUP_HYBRID=yes
156+ fi
154157 CGROUP_UNIFIED=no
155158 CGROUP_SUBSYSTEMS=$( awk ' !/^#/ {print $1}' /proc/cgroups)
156159 for g in ${CGROUP_SUBSYSTEMS} ; do
@@ -352,6 +355,12 @@ function requires() {
352355 skip_me=1
353356 fi
354357 ;;
358+ cgroups_hybrid)
359+ init_cgroup_paths
360+ if [ " $CGROUP_HYBRID " != " yes" ]; then
361+ skip_me=1
362+ fi
363+ ;;
355364 smp)
356365 local cpu_count=$( grep -c ' ^processor' /proc/cpuinfo)
357366 if [ " $cpu_count " -lt 2 ]; then
You can’t perform that action at this time.
0 commit comments