rootless netns: move process to scope only with systemd

When you run podman on a non systemd system we should not try to move the
process under a new systemd scope.

[NO NEW TESTS NEEDED]

Ref #13703

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2022-03-30 12:59:49 +02:00
parent d0d805ba1b
commit 1f1cf7bd40

View File

@ -498,10 +498,13 @@ func (r *Runtime) GetRootlessNetNs(new bool) (*RootlessNetNS, error) {
return nil, err return nil, err
} }
// move to systemd scope to prevent systemd from killing it if utils.RunsOnSystemd() {
err = utils.MoveRootlessNetnsSlirpProcessToUserSlice(cmd.Process.Pid) // move to systemd scope to prevent systemd from killing it
if err != nil { err = utils.MoveRootlessNetnsSlirpProcessToUserSlice(cmd.Process.Pid)
logrus.Errorf("failed to move the rootless netns slirp4netns process to the systemd user.slice: %v", err) if err != nil {
// only log this, it is not fatal but can lead to issues when running podman inside systemd units
logrus.Errorf("failed to move the rootless netns slirp4netns process to the systemd user.slice: %v", err)
}
} }
// build a new resolv.conf file which uses the slirp4netns dns server address // build a new resolv.conf file which uses the slirp4netns dns server address