mirror of
https://github.com/containers/podman.git
synced 2025-06-21 09:28:09 +08:00
rootless: run pause process in its own scope
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -6,9 +6,11 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"log/syslog"
|
"log/syslog"
|
||||||
"os"
|
"os"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
@ -121,6 +123,24 @@ func profileOff(cmd *cobra.Command) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func movePauseProcessToScope() error {
|
||||||
|
pausePidPath, err := util.GetRootlessPauseProcessPidPath()
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
func setupRootless(cmd *cobra.Command, args []string) error {
|
func setupRootless(cmd *cobra.Command, args []string) error {
|
||||||
if !rootless.IsRootless() {
|
if !rootless.IsRootless() {
|
||||||
return nil
|
return nil
|
||||||
@ -206,6 +226,17 @@ func setupRootless(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
became, ret, err := rootless.TryJoinFromFilePaths(pausePidPath, true, paths)
|
became, ret, err := rootless.TryJoinFromFilePaths(pausePidPath, true, paths)
|
||||||
|
if err := movePauseProcessToScope(); err != nil {
|
||||||
|
conf, err := runtime.GetConfig()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if conf.CgroupManager == libpod.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)
|
||||||
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf(err.Error())
|
logrus.Errorf(err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Reference in New Issue
Block a user