Skip to content

Commit

Permalink
abi: fix detection for systemd
Browse files Browse the repository at this point in the history
create a scope everytime we don't own the current cgroup and we are
running on systemd.

Closes: containers#6734

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe authored and mheon committed Aug 20, 2020
1 parent d3ef477 commit ce1389b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/domain/infra/abi/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit ce1389b

Please sign in to comment.