15 Commits

Author SHA1 Message Date
510fa4ebc8 stats: add SystemUsage
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-02-12 11:58:29 +01:00
2511b50800 Use cgroupv2 super magic from golang.org/x/sys/unix
We can use this constant from the already existing sys/unix package
instead of defining it by our own.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-01-21 16:08:29 +01:00
67165b7675 make lint: enable gocritic
`gocritic` is a powerful linter that helps in preventing certain kinds
of errors as well as enforcing a coding style.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-13 14:27:02 +01:00
539b7b6058 Fix error message on podman stats on cgroups v1 rootless environments
podman stats does not work in rootless environments with cgroups V1.
Fix error message and document this fact.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-08-19 07:41:50 -04:00
9873901469 pkg/cgroups: use DBUS session when rootless
use the DBUS user session when running in rootless mode.

Closes: https://github.com/containers/libpod/issues/3801

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-08-14 15:46:07 +02:00
db826d5d75 golangci-lint round #3
this is the third round of preparing to use the golangci-lint on our
code base.

Signed-off-by: baude <bbaude@redhat.com>
2019-07-21 14:22:39 -05:00
c59d08bc77 Merge pull request #3564 from giuseppe/cgroupsv2-no-controllers-last-path
cgroupsv2: do not enable controllers for the last component
2019-07-13 00:21:18 +02:00
6c8ceaf21e cgroupsv2: do not enable controllers for the last component
do not automatically enable the controllers for the last path
component.  It is necessary as once there are enabled controllers in a
cgroup, it won't possible to add processes to it.

Fix conmon being moved to the correct cgroup path when using
--cgroup-manager cgroupfs.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-07-12 12:11:06 +02:00
7b75796a60 cgroups: fix a leak when using cgroupfs
be sure to load all the existing handlers, so that they can also be
freed in addition to the handlers we treat differently.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-07-11 18:07:49 +02:00
1601100b3e cgroups: attempt a recursive rmdir
if the cgroup cannot be deleted, then attempt to delete all its
subdirectories and try again.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-07-11 18:07:48 +02:00
bbe03e61a3 cgroups: support creating cgroupsv2 paths
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>
2019-07-10 10:54:35 +02:00
7423426f73 cgroups: fix times conversion
convert the time we read in microseconds to nanoseconds.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-07-02 12:59:26 +02:00
1778bfa5fe pkg, cgroups: add initial support for cgroup v2
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>
2019-06-26 13:17:05 +02:00
72cf0c81e8 libpod: use pkg/cgroups instead of containerd/cgroups
use the new implementation for dealing with cgroups.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-06-26 13:17:02 +02:00
fa18693813 pkg: new package cgroups
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>
2019-06-26 13:17:01 +02:00