Skip to content

Commit

Permalink
Merge pull request containers#11648 from giuseppe/raise-move-process-…
Browse files Browse the repository at this point in the history
…to-scope-only-with-cgroupv2

utils: raise warning only on cgroupv2
  • Loading branch information
openshift-merge-robot authored Sep 20, 2021
2 parents ddb3844 + eea5d25 commit b906ecb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions utils/utils_supported.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b906ecb

Please sign in to comment.