From 4caca0969863f5b8d13ff377ed1cc24d4033ed1a Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 20 Sep 2021 09:35:24 +0200 Subject: [PATCH 1/2] utils: raise warning only on cgroupv2 if it is not running on cgroup v2, print only a debug message since rootless users cannot create the cgroup. commit 9c1e27fdd536f6026efe3da4360755a3e9135ca8 introduced the regression. [NO TESTS NEEDED] Signed-off-by: Giuseppe Scrivano --- utils/utils.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils/utils.go b/utils/utils.go index 185ac48652..b08630d2f7 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -12,6 +12,7 @@ import ( "sync" "github.com/containers/podman/v3/libpod/define" + "github.com/containers/podman/v3/pkg/cgroups" "github.com/containers/storage/pkg/archive" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -190,7 +191,11 @@ func moveProcessToScope(pidPath, slice, scope string) error { func MovePauseProcessToScope(pausePidPath string) { err := moveProcessToScope(pausePidPath, "user.slice", "podman-pause.scope") if err != nil { - if RunsOnSystemd() { + unified, err := cgroups.IsCgroup2UnifiedMode() + if err != nil { + logrus.Warnf("Failed to detect if running with cgroup unified: %v", err) + } + if RunsOnSystemd() && unified { logrus.Warnf("Failed to add pause process to systemd sandbox cgroup: %v", err) } else { logrus.Debugf("Failed to add pause process to systemd sandbox cgroup: %v", err) From eea5d251267d070d7920008056e3e4d603cae204 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 20 Sep 2021 09:42:35 +0200 Subject: [PATCH 2/2] utils: return error message from StartTransientUnit Signed-off-by: Giuseppe Scrivano --- utils/utils_supported.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/utils_supported.go b/utils/utils_supported.go index ebc870d267..1404e31941 100644 --- a/utils/utils_supported.go +++ b/utils/utils_supported.go @@ -47,10 +47,10 @@ func RunUnderSystemdScope(pid int, slice string, unitName string) error { // 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 err + if err := moveUnderCgroup(cgroup, "", []uint32{uint32(pid)}); err == nil { + return nil } - return nil + // On errors return the original error message we got from StartTransientUnit. } } return err