|
|
b1e4f0 |
From 2ddd2b76b672fa48e38c4d855c749fed395cb1f4 Mon Sep 17 00:00:00 2001
|
|
|
b1e4f0 |
From: Giuseppe Scrivano <gscrivan@redhat.com>
|
|
|
b1e4f0 |
Date: Wed, 8 Dec 2021 09:31:25 +0100
|
|
|
b1e4f0 |
Subject: [PATCH] utils: reintroduce moveToCgroup
|
|
|
b1e4f0 |
|
|
|
b1e4f0 |
commit ee62711136339c5daf38e38859227d85b06fc32a introduced the
|
|
|
b1e4f0 |
regression.
|
|
|
b1e4f0 |
|
|
|
b1e4f0 |
It was mistakenly removed as part of a cleanup, but this code is
|
|
|
b1e4f0 |
needed by another code path, where we move conmon for the exec session
|
|
|
b1e4f0 |
to the same cgroup used by conmon for the process.
|
|
|
b1e4f0 |
|
|
|
b1e4f0 |
Closes: https://github.com/containers/podman/issues/12535
|
|
|
b1e4f0 |
|
|
|
b1e4f0 |
[NO NEW TESTS NEEDED] it fixes a regression in the CI
|
|
|
b1e4f0 |
|
|
|
b1e4f0 |
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
|
|
|
b1e4f0 |
---
|
|
|
b1e4f0 |
utils/utils_supported.go | 9 +++++++++
|
|
|
b1e4f0 |
1 file changed, 9 insertions(+)
|
|
|
b1e4f0 |
|
|
|
b1e4f0 |
diff --git a/utils/utils_supported.go b/utils/utils_supported.go
|
|
|
b1e4f0 |
index 0f0c9a9ba00..1404e319416 100644
|
|
|
b1e4f0 |
--- a/utils/utils_supported.go
|
|
|
b1e4f0 |
+++ b/utils/utils_supported.go
|
|
|
b1e4f0 |
@@ -44,6 +44,15 @@ func RunUnderSystemdScope(pid int, slice string, unitName string) error {
|
|
|
b1e4f0 |
ch := make(chan string)
|
|
|
b1e4f0 |
_, err = conn.StartTransientUnit(unitName, "replace", properties, ch)
|
|
|
b1e4f0 |
if err != nil {
|
|
|
b1e4f0 |
+ // On errors check if the cgroup already exists, if it does move the process there
|
|
|
b1e4f0 |
+ if props, err := conn.GetUnitTypeProperties(unitName, "Scope"); err == nil {
|
|
|
b1e4f0 |
+ if cgroup, ok := props["ControlGroup"].(string); ok && cgroup != "" {
|
|
|
b1e4f0 |
+ if err := moveUnderCgroup(cgroup, "", []uint32{uint32(pid)}); err == nil {
|
|
|
b1e4f0 |
+ return nil
|
|
|
b1e4f0 |
+ }
|
|
|
b1e4f0 |
+ // On errors return the original error message we got from StartTransientUnit.
|
|
|
b1e4f0 |
+ }
|
|
|
b1e4f0 |
+ }
|
|
|
b1e4f0 |
return err
|
|
|
b1e4f0 |
}
|
|
|
b1e4f0 |
|