42 lines
1.5 KiB
Diff
42 lines
1.5 KiB
Diff
From 2ddd2b76b672fa48e38c4d855c749fed395cb1f4 Mon Sep 17 00:00:00 2001
|
|
From: Giuseppe Scrivano <gscrivan@redhat.com>
|
|
Date: Wed, 8 Dec 2021 09:31:25 +0100
|
|
Subject: [PATCH] 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>
|
|
---
|
|
utils/utils_supported.go | 9 +++++++++
|
|
1 file changed, 9 insertions(+)
|
|
|
|
diff --git a/utils/utils_supported.go b/utils/utils_supported.go
|
|
index 0f0c9a9ba00..1404e319416 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
|
|
}
|
|
|