diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2021-01-26 10:51:01 -0500 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2021-01-27 15:16:24 -0500 |
commit | 89bb8a9b368b1f42fb5ff8ca612aa3d4981cff3a (patch) | |
tree | 15d09d9451aa8187f7e265f9fab29c511d5df9fe /pkg/cgroups/cgroups.go | |
parent | 14cc4aaf0a364bf0f4f7f77ec5f58fd79b1cb99e (diff) | |
download | podman-89bb8a9b368b1f42fb5ff8ca612aa3d4981cff3a.tar.gz podman-89bb8a9b368b1f42fb5ff8ca612aa3d4981cff3a.tar.bz2 podman-89bb8a9b368b1f42fb5ff8ca612aa3d4981cff3a.zip |
Don't fail if one of the cgroups is not setup
It is fairly common for certain cgroups controllers to
not be enabled on a system. We should Warn when this happens
versus failing, when doing podman stats command. This way users
can get information from the other controllers.
Fixes: https://github.com/containers/podman/issues/8588
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/cgroups/cgroups.go')
-rw-r--r-- | pkg/cgroups/cgroups.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/pkg/cgroups/cgroups.go b/pkg/cgroups/cgroups.go index c200dd01a..285fd093a 100644 --- a/pkg/cgroups/cgroups.go +++ b/pkg/cgroups/cgroups.go @@ -24,6 +24,7 @@ var ( ErrCgroupDeleted = errors.New("cgroup deleted") // ErrCgroupV1Rootless means the cgroup v1 were attempted to be used in rootless environment ErrCgroupV1Rootless = errors.New("no support for CGroups V1 in rootless environments") + ErrStatCgroup = errors.New("no cgroup available for gathering user statistics") ) // CgroupControl controls a cgroup hierarchy @@ -525,10 +526,19 @@ func (c *CgroupControl) AddPid(pid int) error { // Stat returns usage statistics for the cgroup func (c *CgroupControl) Stat() (*Metrics, error) { m := Metrics{} + found := false for _, h := range handlers { if err := h.Stat(c, &m); err != nil { - return nil, err + if !os.IsNotExist(errors.Cause(err)) { + return nil, err + } + logrus.Warningf("Failed to retrieve cgroup stats: %v", err) + continue } + found = true + } + if !found { + return nil, ErrStatCgroup } return &m, nil } |