66 Commits
Author SHA1 Message Date
Andrei Vagin f010ae01ac Fix a few typos 2025-01-29 21:16:51 -08:00
Koichi Shiraishi 0cf77c02f8 all: remove use io/ioutil deprecated package & fix some deprecated thing
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
2024-10-10 20:36:24 +09:00
Lucas ManningandgVisor bot 8c3abba800 Add documentation that clarifies systemd usage in runsc.
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
2024-05-30 12:26:13 -07:00
Nayana BidariandgVisor bot 094b83e18a Fix CPUUsage() method in cgroup v2 version.
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
2024-03-21 11:10:56 -07:00
Lucas ManningandgVisor bot 42b69d0151 Get limits from parent in cgroupv2 when max is specified in leaf cgroup node.
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
2023-11-03 18:09:54 -07:00
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Kevin KrakauerandgVisor bot d8aa09e04c convert uses of interface{} to any
Done via:
  find . -name "*.go" | xargs sed -i -E 's/interface\{\}/any/g'

PiperOrigin-RevId: 487033228
2022-11-08 13:14:06 -08:00
Shengjing ZhuandShengjing Zhu 7cc16b41df Replace bitset with stdlib math/big
Sync changes in runc https://github.com/opencontainers/runc/pull/3219
2022-09-15 00:09:35 +08:00
Lucas ManningandgVisor bot e0aa478022 Ignore systemd "scope already exists" errors.
This copies the behavior of runc. See  https://github.com/opencontainers/runc/blob/4a51b047036cf16d4f124548c2a7ff24b5640bad/libcontainer/cgroups/systemd/common.go#L150

PiperOrigin-RevId: 471110557
2022-08-30 15:53:26 -07:00
Lucas ManningandgVisor bot 23b21af6d6 Fix JSON marshaling of runsc cgroup configuration.
PiperOrigin-RevId: 470357748
2022-08-26 16:31:54 -07:00
Etienne PerotandgVisor bot de960bb645 Make root_test and containerd tests work on BuildKite on COS.
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
2022-06-24 15:12:55 -07:00
Fabricio VoznikaandgVisor bot a30c81cd80 Only check for systemd when needed
PiperOrigin-RevId: 453311374
2022-06-06 16:47:07 -07:00
Ayush RanjanandgVisor bot f6ed4523dc Reformat codebase.
PiperOrigin-RevId: 449358041
2022-05-17 17:48:35 -07:00
Lucas ManningandgVisor bot d9cffce328 Parse cgroupv2 path only once while scanning mountinfo.
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
2022-03-31 09:17:06 -07:00
Lucas ManningandgVisor bot bf86207401 Add systemd-cgroup support to runsc.
This change adds systemd-cgroup support to cgroupv2 and modifies existing
cgroup tests for systemd support.

Fixes #193

PiperOrigin-RevId: 435457762
2022-03-17 15:03:44 -07:00
Lucas ManningandgVisor bot 28688eb1a5 Support cgroup Install() through systemd.
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
2022-02-24 11:29:46 -08:00
Fabricio VoznikaandgVisor bot 81ea55d8fc Misc changes
Make a few nit changes to cgroups
Better OOM watcher debug logging

PiperOrigin-RevId: 429183470
2022-02-16 17:55:01 -08:00
Lucas ManningandgVisor bot 0f8db423e2 Fix cgroupv2 bug that set the wrong iops throttle.
PiperOrigin-RevId: 425483482
2022-01-31 16:08:11 -08:00
gVisor bot fa4e2fff8a Merge pull request #6821 from dqminh:feature/cgroupv2
PiperOrigin-RevId: 413032543
2021-11-29 18:37:42 -08:00
Andrei VaginandDaniel Dao 102a00ff5e Add an empty line between header and package 2021-11-26 10:14:09 +00:00
Daniel Dao caf6f8d152 cgroupv2: fix CPUQuota parsing
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>
2021-11-26 10:14:08 +00:00
Daniel Dao 881a271ff7 runsc: Add cgroup v2 implementation
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>
2021-11-26 10:14:08 +00:00
Fabricio VoznikaandgVisor bot 82fd0523dc Skip readonly controllers
Some system have controller directories created, but they are
read-only. Handle that case and skip optional controllers.

Closes #5887

PiperOrigin-RevId: 411907208
2021-11-23 15:25:50 -08:00
Fabricio VoznikaandgVisor bot 83eb263b45 Make more cgroup controllers optional
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
2021-11-11 11:24:50 -08:00
Andrei VaginandDaniel Dao 588a28be53 Add common Cgroup interface
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>
2021-11-01 11:06:16 +00:00