summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-09-20 14:17:56 -0400
committerGitHub <noreply@github.com>2021-09-20 14:17:56 -0400
commitf93500810800e85af4de88b99efeaea989db9025 (patch)
treea12daf6fea64b6355b0ac19b2de72c5e7996ae14 /pkg
parentcd09903eff3589d82256a86e144f4a4c5bedccbe (diff)
parent331ce0f7ee2736d5f012ea6a6d2aba77213e3956 (diff)
downloadpodman-f93500810800e85af4de88b99efeaea989db9025.tar.gz
podman-f93500810800e85af4de88b99efeaea989db9025.tar.bz2
podman-f93500810800e85af4de88b99efeaea989db9025.zip
Merge pull request #11624 from giuseppe/3.4-fix-pause-process
[3.4] runtime: move pause process to scope
Diffstat (limited to 'pkg')
-rw-r--r--pkg/domain/infra/abi/system.go44
1 files changed, 2 insertions, 42 deletions
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go
index bc98edd06..e326f26a8 100644
--- a/pkg/domain/infra/abi/system.go
+++ b/pkg/domain/infra/abi/system.go
@@ -3,16 +3,12 @@ package abi
import (
"context"
"fmt"
- "io/ioutil"
"net/url"
"os"
"os/exec"
"path/filepath"
- "strconv"
- "strings"
"github.com/containers/common/pkg/config"
- "github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/domain/entities"
@@ -72,11 +68,7 @@ func (ic *ContainerEngine) SetupRootless(_ context.Context, noMoveProcess bool)
if err != nil {
return err
}
-
- initCommand, err := ioutil.ReadFile("/proc/1/comm")
- // On errors, default to systemd
- runsUnderSystemd := err != nil || strings.TrimRight(string(initCommand), "\n") == "systemd"
-
+ runsUnderSystemd := utils.RunsOnSystemd()
unitName := fmt.Sprintf("podman-%d.scope", os.Getpid())
if runsUnderSystemd || conf.Engine.CgroupManager == config.SystemdCgroupsManager {
if err := utils.RunUnderSystemdScope(os.Getpid(), "user.slice", unitName); err != nil {
@@ -120,18 +112,7 @@ func (ic *ContainerEngine) SetupRootless(_ context.Context, noMoveProcess bool)
}
became, ret, err = rootless.TryJoinFromFilePaths(pausePidPath, true, paths)
-
- if err := movePauseProcessToScope(ic.Libpod); err != nil {
- conf, err2 := ic.Config(context.Background())
- if err2 != nil {
- return err
- }
- if conf.Engine.CgroupManager == config.SystemdCgroupsManager {
- 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)
- }
- }
+ utils.MovePauseProcessToScope(pausePidPath)
if err != nil {
logrus.Error(errors.Wrapf(err, "invalid internal status, try resetting the pause process with %q", os.Args[0]+" system migrate"))
os.Exit(1)
@@ -142,27 +123,6 @@ func (ic *ContainerEngine) SetupRootless(_ context.Context, noMoveProcess bool)
return nil
}
-func movePauseProcessToScope(r *libpod.Runtime) error {
- tmpDir, err := r.TmpDir()
- if err != nil {
- return err
- }
- pausePidPath, err := util.GetRootlessPauseProcessPidPathGivenDir(tmpDir)
- if err != nil {
- return errors.Wrapf(err, "could not get pause process pid file path")
- }
- data, err := ioutil.ReadFile(pausePidPath)
- if err != nil {
- return errors.Wrapf(err, "cannot read pause pid file")
- }
- pid, err := strconv.ParseUint(string(data), 10, 0)
- if err != nil {
- return errors.Wrapf(err, "cannot parse pid file %s", pausePidPath)
- }
-
- return utils.RunUnderSystemdScope(int(pid), "user.slice", "podman-pause.scope")
-}
-
// SystemPrune removes unused data from the system. Pruning pods, containers, volumes and images.
func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.SystemPruneOptions) (*entities.SystemPruneReport, error) {
var systemPruneReport = new(entities.SystemPruneReport)