runc/libcontainer/cgroups
Kir Kolyshkin 59897367c4 cgroups/systemd: allow to set -1 as pids.limit
Currently, both systemd cgroup drivers (v1 and v2) only set
"TasksMax" unit property if the value > 0, so there is no
way to update the limit to -1 / unlimited / infinity / max.

Since systemd driver is backed by fs driver, and both fs and fs2
set the limit of -1 properly, it works, but systemd still has
the old value:

 # runc --systemd-cgroup update $CT --pids-limit 42
 # systemctl show runc-$CT.scope | grep TasksMax
 TasksMax=42
 # cat /sys/fs/cgroup/system.slice/runc-$CT.scope/pids.max
 42

 # ./runc --systemd-cgroup update $CT --pids-limit -1
 # systemctl show runc-$CT.scope | grep TasksMax=
 TasksMax=42
 # cat /sys/fs/cgroup/system.slice/runc-xx77.scope/pids.max
 max

Fix by changing the condition to allow -1 as a valid value.

NOTE other negative values are still being ignored by systemd drivers
(as it was done before). I am not sure whether this is correct, or
should we return an error.

A test case is added.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-05-20 13:20:04 -07:00
..
devices cgroups: add copyright header to devices.Emulator implementation 2020-05-15 11:29:51 +10:00
ebpf configs: use different types for .Devices and .Resources.Devices 2020-05-13 17:38:45 +10:00
fs fix "libcontainer/cgroups/fs/cpuset.go:63:14: undefined: fmt" 2020-05-19 23:38:20 +09:00
fs2 never write empty string to memory.swap.max 2020-05-16 06:52:14 +08:00
fscommon cgroups/fscommon: use errors.Is 2020-04-18 16:16:49 -07:00
systemd cgroups/systemd: allow to set -1 as pids.limit 2020-05-20 13:20:04 -07:00
cgroups.go cgroups: add GetFreezerState() helper to Manager 2020-05-13 17:38:45 +10:00
cgroups_test.go .travis.yml: add Fedora 31 vagrant box (for cgroup2) 2019-10-31 16:53:01 +09:00
cgroups_unsupported.go Move libcontainer into subdirectory 2015-06-21 19:29:15 -07:00
stats.go Add reading of information from cpuacct.usage_all 2020-05-05 08:51:12 +02:00
utils.go libct/cgroups: rm GetClosestMountpointAncestor 2020-05-13 17:32:06 -07:00
utils_test.go libct/cgroups: rm GetClosestMountpointAncestor 2020-05-13 17:32:06 -07:00