Major fixes to systemd cgroup handling

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #507
Approved by: baude
This commit is contained in:
Matthew Heon
2018-03-21 11:28:16 -04:00
committed by Atomic Bot
parent fee9ec1858
commit df83d361e4
6 changed files with 51 additions and 24 deletions

View File

@ -6,7 +6,6 @@ import (
"path/filepath"
"time"
"github.com/containerd/cgroups"
"github.com/containernetworking/cni/pkg/types"
cnitypes "github.com/containernetworking/cni/pkg/types/current"
"github.com/containernetworking/plugins/pkg/ns"
@ -854,9 +853,15 @@ func (c *Container) NamespacePath(ns LinuxNS) (string, error) {
}
// CGroupPath returns a cgroups "path" for a given container.
func (c *Container) CGroupPath() cgroups.Path {
// TODO add support for systemd cgroup paths
return cgroups.StaticPath(filepath.Join(c.config.CgroupParent, fmt.Sprintf("libpod-conmon-%s", c.ID())))
func (c *Container) CGroupPath() (string, error) {
switch c.runtime.config.CgroupManager {
case CgroupfsCgroupsManager:
return filepath.Join(c.config.CgroupParent, fmt.Sprintf("libpod-conmon-%s", c.ID())), nil
case SystemdCgroupsManager:
return filepath.Join(c.config.CgroupParent, createUnitName("libpod", c.ID())), nil
default:
return "", errors.Wrapf(ErrInvalidArg, "unsupported CGroup manager %s in use", c.runtime.config.CgroupManager)
}
}
// RootFsSize returns the root FS size of the container