summaryrefslogtreecommitdiff
path: root/pkg/cgroups/cgroups.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-02-13 15:42:53 +0100
committerGitHub <noreply@github.com>2020-02-13 15:42:53 +0100
commitcd9e6b4143c9b49c3a23f2ba3c1e1c4978c83134 (patch)
tree1a9b2c4d6630fee8ff40eba4666a0aa889a87b9b /pkg/cgroups/cgroups.go
parentf4b5e600a10f92335f46e004e011205d07ee146b (diff)
parent510fa4ebc8271f929753275428ae2b6047ecc8c7 (diff)
downloadpodman-cd9e6b4143c9b49c3a23f2ba3c1e1c4978c83134.tar.gz
podman-cd9e6b4143c9b49c3a23f2ba3c1e1c4978c83134.tar.bz2
podman-cd9e6b4143c9b49c3a23f2ba3c1e1c4978c83134.zip
Merge pull request #5172 from giuseppe/api-fix-cpu-stats
api: fix the CPU stats reported
Diffstat (limited to 'pkg/cgroups/cgroups.go')
-rw-r--r--pkg/cgroups/cgroups.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/pkg/cgroups/cgroups.go b/pkg/cgroups/cgroups.go
index 96786223d..6c5b7978c 100644
--- a/pkg/cgroups/cgroups.go
+++ b/pkg/cgroups/cgroups.go
@@ -536,15 +536,14 @@ func (c *CgroupControl) Stat() (*Metrics, error) {
return &m, nil
}
-func readCgroup2MapFile(ctr *CgroupControl, name string) (map[string][]string, error) {
+func readCgroup2MapPath(path string) (map[string][]string, error) {
ret := map[string][]string{}
- p := filepath.Join(cgroupRoot, ctr.path, name)
- f, err := os.Open(p)
+ f, err := os.Open(path)
if err != nil {
if os.IsNotExist(err) {
return ret, nil
}
- return nil, errors.Wrapf(err, "open file %s", p)
+ return nil, errors.Wrapf(err, "open file %s", path)
}
defer f.Close()
scanner := bufio.NewScanner(f)
@@ -557,7 +556,13 @@ func readCgroup2MapFile(ctr *CgroupControl, name string) (map[string][]string, e
ret[parts[0]] = parts[1:]
}
if err := scanner.Err(); err != nil {
- return nil, errors.Wrapf(err, "parsing file %s", p)
+ return nil, errors.Wrapf(err, "parsing file %s", path)
}
return ret, nil
}
+
+func readCgroup2MapFile(ctr *CgroupControl, name string) (map[string][]string, error) {
+ p := filepath.Join(cgroupRoot, ctr.path, name)
+
+ return readCgroup2MapPath(p)
+}