aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-20 09:05:43 -0400
committerGitHub <noreply@github.com>2021-09-20 09:05:43 -0400
commitb906ecbb5bc887f5123a0f61a5a51782aa34357f (patch)
treea13a8cbec90889361c8dc14f5d4ecf2dbb01fce9
parentddb384451147c4ef9d0307be0cc8dbad6d94970c (diff)
parenteea5d251267d070d7920008056e3e4d603cae204 (diff)
downloadpodman-b906ecbb5bc887f5123a0f61a5a51782aa34357f.tar.gz
podman-b906ecbb5bc887f5123a0f61a5a51782aa34357f.tar.bz2
podman-b906ecbb5bc887f5123a0f61a5a51782aa34357f.zip
Merge pull request #11648 from giuseppe/raise-move-process-to-scope-only-with-cgroupv2
utils: raise warning only on cgroupv2
-rw-r--r--utils/utils.go7
-rw-r--r--utils/utils_supported.go6
2 files changed, 9 insertions, 4 deletions
diff --git a/utils/utils.go b/utils/utils.go
index 185ac4865..b08630d2f 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)
diff --git a/utils/utils_supported.go b/utils/utils_supported.go
index ebc870d26..1404e3194 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