Skip to content

Commit b70f6cc

Browse files
mheonrh-atomic-bot
authored andcommitted
Place Conmon and Container in separate CGroups
Signed-off-by: Matthew Heon <[email protected]> Closes: containers#507 Approved by: baude
1 parent 853c5c4 commit b70f6cc

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

libpod/container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ func (c *Container) NamespacePath(ns LinuxNS) (string, error) {
856856
func (c *Container) CGroupPath() (string, error) {
857857
switch c.runtime.config.CgroupManager {
858858
case CgroupfsCgroupsManager:
859-
return filepath.Join(c.config.CgroupParent, fmt.Sprintf("libpod-conmon-%s", c.ID())), nil
859+
return filepath.Join(c.config.CgroupParent, fmt.Sprintf("libpod-%s", c.ID()), "ctr"), nil
860860
case SystemdCgroupsManager:
861861
return filepath.Join(c.config.CgroupParent, createUnitName("libpod", c.ID())), nil
862862
default:

libpod/oci.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -328,19 +328,15 @@ func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string) (er
328328
logrus.Warnf("Failed to add conmon to systemd sandbox cgroup: %v", err)
329329
}
330330
} else {
331-
cgroupPath, err := ctr.CGroupPath()
331+
cgroupPath := filepath.Join(ctr.config.CgroupParent, fmt.Sprintf("libpod-%s", ctr.ID()), "conmon")
332+
control, err := cgroups.New(cgroups.V1, cgroups.StaticPath(cgroupPath), &spec.LinuxResources{})
332333
if err != nil {
333-
logrus.Errorf("Failed to generate CGroup path for conmon: %v", err)
334+
logrus.Warnf("Failed to add conmon to cgroupfs sandbox cgroup: %v", err)
334335
} else {
335-
control, err := cgroups.New(cgroups.V1, cgroups.StaticPath(cgroupPath), &spec.LinuxResources{})
336-
if err != nil {
336+
// we need to remove this defer and delete the cgroup once conmon exits
337+
// maybe need a conmon monitor?
338+
if err := control.Add(cgroups.Process{Pid: cmd.Process.Pid}); err != nil {
337339
logrus.Warnf("Failed to add conmon to cgroupfs sandbox cgroup: %v", err)
338-
} else {
339-
// we need to remove this defer and delete the cgroup once conmon exits
340-
// maybe need a conmon monitor?
341-
if err := control.Add(cgroups.Process{Pid: cmd.Process.Pid}); err != nil {
342-
logrus.Warnf("Failed to add conmon to cgroupfs sandbox cgroup: %v", err)
343-
}
344340
}
345341
}
346342
}

0 commit comments

Comments
 (0)