@@ -321,19 +321,26 @@ func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string) (er
321321
322322 // Move conmon to specified cgroup
323323 if r .cgroupManager == SystemdCgroupsManager {
324- logrus .Infof ("Running conmon under slice %s and unitName %s" , cgroupParent , createUnitName ("libpod-conmon" , ctr .ID ()))
325- if err = utils .RunUnderSystemdScope (cmd .Process .Pid , cgroupParent , createUnitName ("libpod-conmon" , ctr .ID ())); err != nil {
324+ unitName := createUnitName ("libpod" , ctr .ID ())
325+
326+ logrus .Infof ("Running conmon under slice %s and unitName %s" , cgroupParent , unitName )
327+ if err = utils .RunUnderSystemdScope (cmd .Process .Pid , cgroupParent , unitName ); err != nil {
326328 logrus .Warnf ("Failed to add conmon to systemd sandbox cgroup: %v" , err )
327329 }
328330 } else {
329- control , err := cgroups . New ( cgroups . V1 , cgroups . StaticPath ( filepath . Join ( cgroupParent , "/libpod-conmon-" + ctr .ID ())), & spec. LinuxResources {} )
331+ cgroupPath , err := ctr .CGroupPath ( )
330332 if err != nil {
331- logrus .Warnf ("Failed to add conmon to cgroupfs sandbox cgroup : %v" , err )
333+ logrus .Errorf ("Failed to generate CGroup path for conmon : %v" , err )
332334 } else {
333- // we need to remove this defer and delete the cgroup once conmon exits
334- // maybe need a conmon monitor?
335- if err := control .Add (cgroups.Process {Pid : cmd .Process .Pid }); err != nil {
335+ control , err := cgroups .New (cgroups .V1 , cgroups .StaticPath (cgroupPath ), & spec.LinuxResources {})
336+ if err != nil {
336337 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+ }
337344 }
338345 }
339346 }
0 commit comments