From b70f6cc04a831478b2c81094b6bfe80bfed6a687 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 7 May 2018 14:44:38 -0400 Subject: Place Conmon and Container in separate CGroups Signed-off-by: Matthew Heon Closes: #507 Approved by: baude --- libpod/container.go | 2 +- 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) - } } } } -- cgit v1.2.3-54-g00ecf