diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-05-07 14:44:38 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-05-11 14:43:57 +0000 |
commit | b70f6cc04a831478b2c81094b6bfe80bfed6a687 (patch) | |
tree | 5e0329fcf0ae5cfd0e32cc8d26a28b9cea3da58f | |
parent | 853c5c41f1a0f65815674cce0777a20de24c8309 (diff) | |
download | podman-b70f6cc04a831478b2c81094b6bfe80bfed6a687.tar.gz podman-b70f6cc04a831478b2c81094b6bfe80bfed6a687.tar.bz2 podman-b70f6cc04a831478b2c81094b6bfe80bfed6a687.zip |
Place Conmon and Container in separate CGroups
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #507
Approved by: baude
-rw-r--r-- | libpod/container.go | 2 | ||||
-rw-r--r-- | libpod/oci.go | 16 |
2 files changed, 7 insertions, 11 deletions
diff --git a/libpod/container.go b/libpod/container.go index 6a48363c9..1e3b923c0 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -856,7 +856,7 @@ func (c *Container) NamespacePath(ns LinuxNS) (string, error) { 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 + return filepath.Join(c.config.CgroupParent, fmt.Sprintf("libpod-%s", c.ID()), "ctr"), nil case SystemdCgroupsManager: return filepath.Join(c.config.CgroupParent, createUnitName("libpod", c.ID())), nil default: diff --git a/libpod/oci.go b/libpod/oci.go index 3b24f2c23..4dbf5526d 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -328,19 +328,15 @@ func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string) (er logrus.Warnf("Failed to add conmon to systemd sandbox cgroup: %v", err) } } else { - cgroupPath, err := ctr.CGroupPath() + cgroupPath := filepath.Join(ctr.config.CgroupParent, fmt.Sprintf("libpod-%s", ctr.ID()), "conmon") + control, err := cgroups.New(cgroups.V1, cgroups.StaticPath(cgroupPath), &spec.LinuxResources{}) if err != nil { - logrus.Errorf("Failed to generate CGroup path for conmon: %v", err) + logrus.Warnf("Failed to add conmon to cgroupfs sandbox cgroup: %v", err) } else { - control, err := cgroups.New(cgroups.V1, cgroups.StaticPath(cgroupPath), &spec.LinuxResources{}) - if err != nil { + // we need to remove this defer and delete the cgroup once conmon exits + // maybe need a conmon monitor? + if err := control.Add(cgroups.Process{Pid: cmd.Process.Pid}); err != nil { logrus.Warnf("Failed to add conmon to cgroupfs sandbox cgroup: %v", err) - } else { - // we need to remove this defer and delete the cgroup once conmon exits - // maybe need a conmon monitor? - if err := control.Add(cgroups.Process{Pid: cmd.Process.Pid}); err != nil { - logrus.Warnf("Failed to add conmon to cgroupfs sandbox cgroup: %v", err) - } } } } |