File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -320,6 +320,34 @@ convert_hugetlb_size() {
320320 done
321321}
322322
323+ # https://github.com/opencontainers/runc/issues/4014.
324+ @test " runc run (pids.limit=0 is 0)" {
325+ [ $EUID -ne 0 ] && requires rootless_cgroup
326+
327+ set_cgroups_path
328+ update_config ' .linux.resources.pids.limit = 0'
329+
330+ runc run -d --console-socket " $CONSOLE_SOCKET " test_pids
331+ [ " $status " -eq 0 ]
332+ # systemd doesn't support TasksMax=0 so runc will silently remap it to 1.
333+ check_cgroup_value " pids.max" " 1" " 0"
334+ check_systemd_value " TasksMax" " 1" " 0"
335+ }
336+
337+ # https://github.com/opencontainers/runc/issues/4014.
338+ @test " runc run (pids.limit=-1 means unlimited)" {
339+ [ $EUID -ne 0 ] && requires rootless_cgroup
340+
341+ set_cgroups_path
342+ update_config ' .linux.resources.pids.limit = -1'
343+
344+ runc run -d --console-socket " $CONSOLE_SOCKET " test_pids
345+ [ " $status " -eq 0 ]
346+ check_cgroup_value " pids.max" " max"
347+ # systemd < v227 shows UINT64_MAX instead of "infinity".
348+ check_systemd_value " TasksMax" " infinity" " 18446744073709551615"
349+ }
350+
323351@test " runc run (cgroup v2 resources.unified only)" {
324352 requires root cgroups_v2
325353
@@ -386,6 +414,7 @@ convert_hugetlb_size() {
386414 set_cgroups_path
387415 # CPU shares of 3333 corresponds to CPU weight of 128.
388416 update_config ' .linux.resources.memory |= {"limit": 33554432}
417+ | .linux.resources.pids.limit = 100
389418 | .linux.resources.cpu |= {
390419 "shares": 3333,
391420 "quota": 40000,
Original file line number Diff line number Diff line change 330330 check_cpu_shares 100
331331}
332332
333+ @test " update pids.limit" {
334+ [ $EUID -ne 0 ] && requires rootless_cgroup
335+
336+ runc run -d --console-socket " $CONSOLE_SOCKET " test_update
337+ [ " $status " -eq 0 ]
338+
339+ check_cgroup_value " pids.max" 20
340+ check_systemd_value " TasksMax" 20
341+
342+ runc update test_update --pids-limit 12345
343+ [ " $status " -eq 0 ]
344+
345+ check_cgroup_value " pids.max" " 12345"
346+ check_systemd_value " TasksMax" " 12345"
347+
348+ runc update test_update --pids-limit -1
349+ [ " $status " -eq 0 ]
350+
351+ check_cgroup_value " pids.max" " max"
352+ # systemd < v227 shows UINT64_MAX instead of "infinity".
353+ check_systemd_value " TasksMax" " infinity" " 18446744073709551615"
354+
355+ runc update test_update --pids-limit 0
356+ [ " $status " -eq 0 ]
357+
358+ # systemd doesn't support TasksMax=0 so runc will silently remap it to 1.
359+ check_cgroup_value " pids.max" " 0" " 1"
360+ check_systemd_value " TasksMax" " 0" " 1"
361+ }
362+
333363@test " cpu burst" {
334364 [ $EUID -ne 0 ] && requires rootless_cgroup
335365 requires cgroups_cpu_burst
You can’t perform that action at this time.
0 commit comments