diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2020-06-05 10:44:16 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2020-06-05 13:01:57 -0400 |
commit | c8f57b71a4255938efa23fec37c59181c1c657e4 (patch) | |
tree | 0195dcfa6421bbb079e2b75918250eb5e7d4a2ae /cmd/podman | |
parent | c448c03269139dabf6f6fa7ff0fedb2291018b2a (diff) | |
download | podman-c8f57b71a4255938efa23fec37c59181c1c657e4.tar.gz podman-c8f57b71a4255938efa23fec37c59181c1c657e4.tar.bz2 podman-c8f57b71a4255938efa23fec37c59181c1c657e4.zip |
Fix handling of systemd.
Systemd enablement has to happen on the server side, since we need
check if the image is running systemd.
Also need to make sure user setting the StopSignal is not overriden on the
server side. But if not set and using systemd, we set it correctly.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/common/create.go | 2 | ||||
-rw-r--r-- | cmd/podman/common/create_opts.go | 2 | ||||
-rw-r--r-- | cmd/podman/common/specgen.go | 34 |
3 files changed, 8 insertions, 30 deletions
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go index 4d4dea0d2..86cd51643 100644 --- a/cmd/podman/common/create.go +++ b/cmd/podman/common/create.go @@ -424,7 +424,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet { "Sysctl options", ) createFlags.StringVar( - &cf.SystemdD, + &cf.Systemd, "systemd", "true", `Run container in systemd mode ("true"|"false"|"always")`, ) diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go index 8b38e3b47..4cba5daf7 100644 --- a/cmd/podman/common/create_opts.go +++ b/cmd/podman/common/create_opts.go @@ -85,7 +85,7 @@ type ContainerCLIOpts struct { SubUIDName string SubGIDName string Sysctl []string - SystemdD string + Systemd string TmpFS []string TTY bool UIDMap []string diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index 1fabff378..26003b40f 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -3,7 +3,6 @@ package common import ( "fmt" "os" - "path/filepath" "strconv" "strings" "time" @@ -285,16 +284,13 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string s.NetNS = c.Net.Network } - // STOP SIGNAL - signalString := "TERM" if sig := c.StopSignal; len(sig) > 0 { - signalString = sig - } - stopSignal, err := util.ParseSignal(signalString) - if err != nil { - return err + stopSignal, err := util.ParseSignal(sig) + if err != nil { + return err + } + s.StopSignal = &stopSignal } - s.StopSignal = &stopSignal // ENVIRONMENT VARIABLES // @@ -439,25 +435,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string s.ImageVolumeMode = "anonymous" } - systemd := c.SystemdD == "always" - if !systemd && command != nil { - x, err := strconv.ParseBool(c.SystemdD) - if err != nil { - return errors.Wrapf(err, "cannot parse bool %s", c.SystemdD) - } - if x && (command[0] == "/usr/sbin/init" || command[0] == "/sbin/init" || (filepath.Base(command[0]) == "systemd")) { - systemd = true - } - } - if systemd { - if s.StopSignal == nil { - stopSignal, err = util.ParseSignal("RTMIN+3") - if err != nil { - return errors.Wrapf(err, "error parsing systemd signal") - } - s.StopSignal = &stopSignal - } - } + s.Systemd = c.Systemd if s.ResourceLimits == nil { s.ResourceLimits = &specs.LinuxResources{} } |