summaryrefslogtreecommitdiff
path: root/pkg/cgroups/cpu.go
Commit message (Collapse)AuthorAge
* Enable whitespace linterPaul Holzinger2021-02-11
| | | | | | | | Use the whitespace linter and fix the reported problems. [NO TESTS NEEDED] Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
* Remove excessive error wrappingKir Kolyshkin2020-10-05
| | | | | | | | | | | | | | | | | In case os.Open[File], os.Mkdir[All], ioutil.ReadFile and the like fails, the error message already contains the file name and the operation that fails, so there is no need to wrap the error with something like "open %s failed". While at it - replace a few places with os.Open, ioutil.ReadAll with ioutil.ReadFile. - replace errors.Wrapf with errors.Wrap for cases where there are no %-style arguments. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
* Turn on More lintersDaniel J Walsh2020-06-15
| | | | | | | | | - misspell - prealloc - unparam - nakedret Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
* stats: add SystemUsageGiuseppe Scrivano2020-02-12
| | | | Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* cgroups: read correctly the CPU statsGiuseppe Scrivano2019-11-01
| | | | | | the two values were incorrectly switched. Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
* cgroups: attempt a recursive rmdirGiuseppe Scrivano2019-07-11
| | | | | | | if the cgroup cannot be deleted, then attempt to delete all its subdirectories and try again. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* cgroups: skip not existing cpuacct filesGiuseppe Scrivano2019-07-10
| | | | | | | | if the cpuacct file doesn't exist, ignore it instead of erroring out. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1728242 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* cgroups: support creating cgroupsv2 pathsGiuseppe Scrivano2019-07-10
| | | | | | | | | drop the limitation of not supporting creating new cgroups v2 paths. Every controller enabled /sys/fs/cgroup will be propagated down to the created path. This won't work for rootless cgroupsv2, but it is not an issue for now, as this code is used only by CRI-O. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* cgroups: fix times conversionGiuseppe Scrivano2019-07-02
| | | | | | convert the time we read in microseconds to nanoseconds. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* pkg, cgroups: add initial support for cgroup v2Giuseppe Scrivano2019-06-26
| | | | | | | | | | | | | | | | | This is an initial implementation of cgroup v2 support for pkg/cgroups. It currently works with crun, with this patch: https://github.com/giuseppe/crun/pull/49). It adds the pieces for: - set PID limit to 1 - retrieve stats so that "podman stats" work. the only missing part is the support for reading per CPU stats (that is cpuacct.usage_percpu on cgroup v1), so for now it always returns an empty result. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* pkg: new package cgroupsGiuseppe Scrivano2019-06-26
provide a package for managing cgroups. This is not supposed to be a complete implementation with all the features supported by cgroups, but it is a minimal implementation designed around what libpod needs and it is currently using. For example, it is currently possible to Apply only the pids limit, as it is used by libpod for stopping containers, any other Apply will just fail. The main goal here is to have a minimal library where we have full control, so we can start playing with cgroup v2. When the need arises, we can add more features. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>