summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2017-12-19 14:41:23 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2017-12-19 20:18:14 +0000
commit44a3187830aa634a8a7bf7f2985d17a4d7927c97 (patch)
treeb946771897e9e4a51a1f65ae2c403a4d8dabc895
parent94a810751539afeb1590ccc1a9745f1d5767fda2 (diff)
downloadpodman-44a3187830aa634a8a7bf7f2985d17a4d7927c97.tar.gz
podman-44a3187830aa634a8a7bf7f2985d17a4d7927c97.tar.bz2
podman-44a3187830aa634a8a7bf7f2985d17a4d7927c97.zip
Finish implementing stop signal parsing
Stop Signal from kpod create/run was not fully plumbed in, This will pass the stopsignal into the container database on create and run of containers. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #156 Approved by: mheon
-rw-r--r--cmd/podman/create.go13
-rw-r--r--cmd/podman/spec.go1
-rw-r--r--libpod/options.go5
3 files changed, 15 insertions, 4 deletions
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index 79f08220d..d3e14742b 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -7,8 +7,10 @@ import (
"os"
"strconv"
"strings"
+ "syscall"
"github.com/docker/docker/api/types/container"
+ "github.com/docker/docker/pkg/signal"
"github.com/docker/go-units"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
@@ -107,7 +109,7 @@ type createConfig struct {
Rm bool //rm
ShmDir string
SigProxy bool //sig-proxy
- StopSignal string // stop-signal
+ StopSignal syscall.Signal // stop-signal
StopTimeout int64 // stop-timeout
StorageOpts []string //storage-opt
Sysctl map[string]string //sysctl
@@ -415,6 +417,13 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime) (*createConfig, er
}
shmDir = ctr.ShmDir()
}
+ stopSignal := syscall.SIGTERM
+ if c.IsSet("stop-signal") {
+ stopSignal, err = signal.ParseSignal(c.String("stop-signal"))
+ if err != nil {
+ return nil, err
+ }
+ }
config := &createConfig{
Runtime: runtime,
@@ -484,7 +493,7 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime) (*createConfig, er
Rm: c.Bool("rm"),
ShmDir: shmDir,
SigProxy: c.Bool("sig-proxy"),
- StopSignal: c.String("stop-signal"),
+ StopSignal: stopSignal,
StopTimeout: c.Int64("stop-timeout"),
StorageOpts: c.StringSlice("storage-opt"),
Sysctl: sysctl,
diff --git a/cmd/podman/spec.go b/cmd/podman/spec.go
index 550f74218..dc6e24c24 100644
--- a/cmd/podman/spec.go
+++ b/cmd/podman/spec.go
@@ -558,6 +558,7 @@ func (c *createConfig) GetContainerCreateOptions() ([]libpod.CtrCreateOption, er
// TODO parse ports into libpod format and include
// TODO should not happen if --net=host
options = append(options, libpod.WithNetNS([]ocicni.PortMapping{}))
+ options = append(options, libpod.WithStopSignal(c.StopSignal))
return options, nil
}
diff --git a/libpod/options.go b/libpod/options.go
index 8720c3639..a0894c0e3 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -3,6 +3,7 @@ package libpod
import (
"fmt"
"path/filepath"
+ "syscall"
"github.com/containers/storage"
"github.com/containers/storage/pkg/idtools"
@@ -396,7 +397,7 @@ func WithName(name string) CtrCreateOption {
}
// WithStopSignal sets the signal that will be sent to stop the container
-func WithStopSignal(signal uint) CtrCreateOption {
+func WithStopSignal(signal syscall.Signal) CtrCreateOption {
return func(ctr *Container) error {
if ctr.valid {
return ErrCtrFinalized
@@ -408,7 +409,7 @@ func WithStopSignal(signal uint) CtrCreateOption {
return errors.Wrapf(ErrInvalidArg, "stop signal cannot be greater than 64 (SIGRTMAX)")
}
- ctr.config.StopSignal = signal
+ ctr.config.StopSignal = uint(signal)
return nil
}