diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-06-19 13:07:23 +0200 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-06-26 13:17:05 +0200 |
commit | 1778bfa5fef337158537a77344300e1a755a7ffe (patch) | |
tree | 1c384616b25d1386be0c448797aafe2b5f03f51c /pkg/cgroups/cpuset.go | |
parent | 5d25a4793d465896fd1762735c8bb593c4aefdfd (diff) | |
download | podman-1778bfa5fef337158537a77344300e1a755a7ffe.tar.gz podman-1778bfa5fef337158537a77344300e1a755a7ffe.tar.bz2 podman-1778bfa5fef337158537a77344300e1a755a7ffe.zip |
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>
Diffstat (limited to 'pkg/cgroups/cpuset.go')
-rw-r--r-- | pkg/cgroups/cpuset.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pkg/cgroups/cpuset.go b/pkg/cgroups/cpuset.go index 15c649e46..9aef493c9 100644 --- a/pkg/cgroups/cpuset.go +++ b/pkg/cgroups/cpuset.go @@ -8,6 +8,7 @@ import ( "strings" spec "github.com/opencontainers/runtime-spec/specs-go" + "github.com/pkg/errors" ) type cpusetHandler struct { @@ -20,7 +21,7 @@ func cpusetCopyFileFromParent(dir, file string) ([]byte, error) { path := filepath.Join(dir, file) data, err := ioutil.ReadFile(path) if err != nil { - return nil, err + return nil, errors.Wrapf(err, "open %s", path) } if len(strings.Trim(string(data), "\n")) != 0 { return data, nil @@ -30,7 +31,7 @@ func cpusetCopyFileFromParent(dir, file string) ([]byte, error) { return nil, err } if err := ioutil.WriteFile(path, data, 0644); err != nil { - return nil, err + return nil, errors.Wrapf(err, "write %s", path) } return data, nil } @@ -53,13 +54,13 @@ func (c *cpusetHandler) Apply(ctr *CgroupControl, res *spec.LinuxResources) erro if res.CPU == nil { return nil } - return fmt.Errorf("function not implemented yet") + return fmt.Errorf("cpuset apply not implemented yet") } // Create the cgroup func (c *cpusetHandler) Create(ctr *CgroupControl) (bool, error) { if ctr.cgroup2 { - return false, fmt.Errorf("function not implemented yet") + return false, fmt.Errorf("cpuset create not implemented for cgroup v2") } created, err := ctr.createCgroupDirectory(CPUset) |