This change also transforms empty paths to match the spec described in the new
docs and logs a warning if runsc detects a systemd-like path without
`--systemd-cgroup`.
Fixes#10264
PiperOrigin-RevId: 638743361
CPUUsage() returns the CPU usage used in calculating the pod CPU utilization.
The cgroup v1 version returns this value in nanoseconds,but the v2 version was
returning in microseconds which resulted in incorrect CPU usage values when
cgroupv2 was used as default.
Fix this by changing the return value of CPUUsage() in cgroupv2 to nanoseconds
PiperOrigin-RevId: 617903260
Without this fix, incorrect values were passed to --total-memory and --num-cpu.
This meant applications were reading incorrect values from /proc/meminfo, etc.
while the external cgroups were enforcing the correct limits. This can lead to
bad/surprising app behavior.
Fixes#9850
PiperOrigin-RevId: 579352625
When running in COS in a container, things are different when accessing
process or cgroup data.
This CL uses the `HOST_PROCFS_MOUNTPOINT` and `HOST_CGROUPFS_MOUNTPOINT`
environment variables as alternate roots for `/proc` and `/sys/fs/cgroup` in
`root_test` and in other related places.
Also includes some minor refactors:
- Factor out code to get the parent PID of a child PID to its own function
- Fix some typos
PiperOrigin-RevId: 457102457
Some systems have multiple cgroup2 mounts. In these cases, loadPathsHelper
incorrectly attempts to overwrite `paths[cgroup2Key]` with an already
processed value, which causes an error in filepath.Rel.
Fixes#7334
PiperOrigin-RevId: 438583982
This change implements Install() though systemd and adds associated tests.
The properties saved by the systemdCgroup object will be applied during
Join(), which will be added in a later change.
PiperOrigin-RevId: 430751223
CPUQuota can return "max PERIOD", in this case, we detect "max"
and return `-1, nil`, which for the current usecase of detecting
cpu-num from quota should be sufficient.
Signed-off-by: Daniel Dao <dqminh89@gmail.com>
Adds support for cgroupv2 based on the common cgroup interface.
The cgroupv2 implementation mostly mirrors the structure of cgroupv1,
with many helper functions derived from containerd/cgroups and opencontainers/runc
implementations. We implemented the following controllers: cpu, cpuset, memory,
io, pids, hugetlb.
In order to avoid upgrading containerd dependency (to get oom poller
implementation), we copied the oom poller implementation for cgroupv2
into shim/oom_v2.go. This requires containerd/cgroups dependency to have
cgroupv2 support which we already have.
Signed-off-by: Daniel Dao <dqminh89@gmail.com>
Some system have controller directories created, but they are
read-only. Handle that case and skip optional controllers.
Closes#5887
PiperOrigin-RevId: 411907208
Mark all noop cgroups as optional, after all there is no harm in skipping them.
Make pids cgroup optional because they are not present on Synology NAS.
Closes#6856
PiperOrigin-RevId: 409197613
This is part of cgroupv2 patch set. Here we add a Cgroup interface that
both v1 and v2 need to conform to, and port cgroupv1 to use that first.
Signed-off-by: Daniel Dao <dqminh89@gmail.com>