Skip to content

Commit

Permalink
Merge pull request containers#12538 from giuseppe/fix-12535
Browse files Browse the repository at this point in the history
utils: reintroduce moveToCgroup
  • Loading branch information
openshift-merge-robot authored Dec 8, 2021
2 parents 3b21ba2 + 0999245 commit 31be3a9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions utils/utils_supported.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ func RunUnderSystemdScope(pid int, slice string, unitName string) error {
ch := make(chan string)
_, err = conn.StartTransientUnit(unitName, "replace", properties, ch)
if err != nil {
// On errors check if the cgroup already exists, if it does move the process there
if props, err := conn.GetUnitTypeProperties(unitName, "Scope"); err == nil {
if cgroup, ok := props["ControlGroup"].(string); ok && cgroup != "" {
if err := moveUnderCgroup(cgroup, "", []uint32{uint32(pid)}); err == nil {
return nil
}
// On errors return the original error message we got from StartTransientUnit.
}
}
return err
}

Expand Down

0 comments on commit 31be3a9

Please sign in to comment.