diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-12-08 14:38:17 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-08 14:38:17 +0000 |
commit | 7472aa112a608d147fd1fa3cb7e7674f8c1511c5 (patch) | |
tree | 3cee7a874f0befe3426aa5f3f8dbfa3538a9c8a1 | |
parent | 49f589d7c36b6d52105a94493baf1664a3ada79c (diff) | |
parent | 2ddd2b76b672fa48e38c4d855c749fed395cb1f4 (diff) | |
download | podman-7472aa112a608d147fd1fa3cb7e7674f8c1511c5.tar.gz podman-7472aa112a608d147fd1fa3cb7e7674f8c1511c5.tar.bz2 podman-7472aa112a608d147fd1fa3cb7e7674f8c1511c5.zip |
Merge pull request #12540 from edsantiago/backport_movetocgroup
[v3.4] backport: utils: reintroduce moveToCgroup
-rw-r--r-- | utils/utils_supported.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/utils/utils_supported.go b/utils/utils_supported.go index 0f0c9a9ba..1404e3194 100644 --- a/utils/utils_supported.go +++ b/utils/utils_supported.go @@ -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 } |