File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -324,6 +324,36 @@ convert_hugetlb_size() {
324324 done
325325}
326326
327+ # https://github.com/opencontainers/runc/issues/4014.
328+ @test " runc run (pids.limit=0 is 0)" {
329+ [ $EUID -ne 0 ] && requires rootless_cgroup
330+ requires cgroups_pids
331+
332+ set_cgroups_path
333+ update_config ' .linux.resources.pids.limit = 0'
334+
335+ runc run -d --console-socket " $CONSOLE_SOCKET " test_pids
336+ [ " $status " -eq 0 ]
337+ # systemd doesn't support TasksMax=0 so runc will silently remap it to 1.
338+ check_cgroup_value " pids.max" " 1"
339+ check_systemd_value " TasksMax" " 1"
340+ }
341+
342+ # https://github.com/opencontainers/runc/issues/4014.
343+ @test " runc run (pids.limit=-1 means unlimited)" {
344+ [ $EUID -ne 0 ] && requires rootless_cgroup
345+ requires cgroups_pids
346+
347+ set_cgroups_path
348+ update_config ' .linux.resources.pids.limit = -1'
349+
350+ runc run -d --console-socket " $CONSOLE_SOCKET " test_pids
351+ [ " $status " -eq 0 ]
352+ check_cgroup_value " pids.max" " max"
353+ # systemd < v227 shows UINT64_MAX instead of "infinity".
354+ check_systemd_value " TasksMax" " infinity" " 18446744073709551615"
355+ }
356+
327357@test " runc run (cgroup v2 resources.unified only)" {
328358 requires root cgroups_v2
329359
@@ -390,6 +420,7 @@ convert_hugetlb_size() {
390420 set_cgroups_path
391421 # CPU shares of 3333 corresponds to CPU weight of 128.
392422 update_config ' .linux.resources.memory |= {"limit": 33554432}
423+ | .linux.resources.pids.limit = 100
393424 | .linux.resources.cpu |= {
394425 "shares": 3333,
395426 "quota": 40000,
Original file line number Diff line number Diff line change 327327 check_cpu_shares 100
328328}
329329
330+ @test " update pids.limit" {
331+ [ $EUID -ne 0 ] && requires rootless_cgroup
332+ requires cgroups_pids
333+
334+ runc run -d --console-socket " $CONSOLE_SOCKET " test_update
335+ [ " $status " -eq 0 ]
336+
337+ check_cgroup_value " pids.max" 20
338+ check_systemd_value " TasksMax" 20
339+
340+ runc update test_update --pids-limit 12345
341+ [ " $status " -eq 0 ]
342+
343+ check_cgroup_value " pids.max" " 12345"
344+ check_systemd_value " TasksMax" " 12345"
345+
346+ runc update test_update --pids-limit -1
347+ [ " $status " -eq 0 ]
348+
349+ check_cgroup_value " pids.max" " max"
350+ # systemd < v227 shows UINT64_MAX instead of "infinity".
351+ check_systemd_value " TasksMax" " infinity" " 18446744073709551615"
352+
353+ runc update test_update --pids-limit 0
354+ [ " $status " -eq 0 ]
355+
356+ # systemd doesn't support TasksMax=0 so runc will silently remap it to 1.
357+ check_cgroup_value " pids.max" " 1"
358+ check_systemd_value " TasksMax" " 1"
359+ }
360+
330361@test " cpu burst" {
331362 [ $EUID -ne 0 ] && requires rootless_cgroup
332363 requires cgroups_cpu_burst
You can’t perform that action at this time.
0 commit comments