diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2021-12-08 09:31:25 +0100 |
---|---|---|
committer | Ed Santiago <santiago@redhat.com> | 2021-12-08 04:54:49 -0700 |
commit | 2ddd2b76b672fa48e38c4d855c749fed395cb1f4 (patch) | |
tree | 3cee7a874f0befe3426aa5f3f8dbfa3538a9c8a1 | |
parent | 49f589d7c36b6d52105a94493baf1664a3ada79c (diff) | |
download | podman-2ddd2b76b672fa48e38c4d855c749fed395cb1f4.tar.gz podman-2ddd2b76b672fa48e38c4d855c749fed395cb1f4.tar.bz2 podman-2ddd2b76b672fa48e38c4d855c749fed395cb1f4.zip |
utils: reintroduce moveToCgroup
commit ee62711136339c5daf38e38859227d85b06fc32a introduced the
regression.
It was mistakenly removed as part of a cleanup, but this code is
needed by another code path, where we move conmon for the exec session
to the same cgroup used by conmon for the process.
Closes: https://github.com/containers/podman/issues/12535
[NO NEW TESTS NEEDED] it fixes a regression in the CI
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
-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 } |