summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2020-08-17 15:58:16 +0200
committerMatthew Heon <matthew.heon@pm.me>2020-08-20 12:24:38 -0400
commitce1389bde7c62ef4eaf9ed8b2f0a68a4c14bbb9d (patch)
treeb711e0f12aba92bf00e04ad8e3ce5bdad57b7f40
parentd3ef4770d4e33f3f6c12895b726320b9c9f311c2 (diff)
downloadpodman-ce1389bde7c62ef4eaf9ed8b2f0a68a4c14bbb9d.tar.gz
podman-ce1389bde7c62ef4eaf9ed8b2f0a68a4c14bbb9d.tar.bz2
podman-ce1389bde7c62ef4eaf9ed8b2f0a68a4c14bbb9d.zip
abi: fix detection for systemd
create a scope everytime we don't own the current cgroup and we are running on systemd. Closes: https://github.com/containers/podman/issues/6734 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
-rw-r--r--pkg/domain/infra/abi/system.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go
index 435902ded..043dfe49e 100644
--- a/pkg/domain/infra/abi/system.go
+++ b/pkg/domain/infra/abi/system.go
@@ -70,8 +70,13 @@ func (ic *ContainerEngine) SetupRootless(_ context.Context, cmd *cobra.Command)
if err != nil {
return err
}
+
+ initCommand, err := ioutil.ReadFile("/proc/1/comm")
+ // On errors, default to systemd
+ runsUnderSystemd := err != nil || string(initCommand) == "systemd"
+
unitName := fmt.Sprintf("podman-%d.scope", os.Getpid())
- if conf.Engine.CgroupManager == config.SystemdCgroupsManager {
+ if runsUnderSystemd || conf.Engine.CgroupManager == config.SystemdCgroupsManager {
if err := utils.RunUnderSystemdScope(os.Getpid(), "user.slice", unitName); err != nil {
logrus.Warnf("Failed to add podman to systemd sandbox cgroup: %v", err)
}