summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2021-12-08 09:31:25 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2021-12-08 09:31:31 +0100
commit0999245e40b0fd56e98ad7149556d5879646b3ac (patch)
tree9a8833e696bf579c168df5719e12ddbb59b4cb45 /utils
parent3b21ba2f623da5a4228a6236c684d1d0b245f240 (diff)
downloadpodman-0999245e40b0fd56e98ad7149556d5879646b3ac.tar.gz
podman-0999245e40b0fd56e98ad7149556d5879646b3ac.tar.bz2
podman-0999245e40b0fd56e98ad7149556d5879646b3ac.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>
Diffstat (limited to 'utils')
-rw-r--r--utils/utils_supported.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/utils/utils_supported.go b/utils/utils_supported.go
index be200509b..064d9e024 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
}