Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cgroupv2: use "max" for negative values
Cgroup v1 kernel doc [1] says: > We can write "-1" to reset the ``*.limit_in_bytes(unlimited)``. and cgroup v2 kernel documentation [2] says: > - If a controller implements an absolute resource guarantee and/or > limit, the interface files should be named "min" and "max" > respectively. If a controller implements best effort resource > guarantee and/or limit, the interface files should be named "low" > and "high" respectively. > > In the above four control files, the special token "max" should be > used to represent upward infinity for both reading and writing. Allow -1 value to still be used for v2, converting it to "max" where it makes sense to do so. This fixes the following issue: > runc update test_update --memory-swap -1: > error while setting cgroup v2: [write /sys/fs/cgroup/machine.slice/runc-cgroups-integration-test.scope/memory.swap.max: invalid argument > failed to write "-1" to "/sys/fs/cgroup/machine.slice/runc-cgroups-integration-test.scope/memory.swap.max" > github.com/opencontainers/runc/libcontainer/cgroups/fscommon.WriteFile > /home/kir/go/src/github.com/opencontainers/runc/libcontainer/cgroups/fscommon/fscommon.go:21 > github.com/opencontainers/runc/libcontainer/cgroups/fs2.setMemory > /home/kir/go/src/github.com/opencontainers/runc/libcontainer/cgroups/fs2/memory.go:20 > github.com/opencontainers/runc/libcontainer/cgroups/fs2.(*manager).Set > /home/kir/go/src/github.com/opencontainers/runc/libcontainer/cgroups/fs2/fs2.go:175 > github.com/opencontainers/runc/libcontainer/cgroups/systemd.(*UnifiedManager).Set > /home/kir/go/src/github.com/opencontainers/runc/libcontainer/cgroups/systemd/unified_hierarchy.go:290 > github.com/opencontainers/runc/libcontainer.(*linuxContainer).Set > /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:211 [1] linux/Documentation/admin-guide/cgroup-v1/memory.rst [2] linux/Documentation/admin-guide/cgroup-v2.rst Signed-off-by: Kir Kolyshkin <[email protected]>
- Loading branch information