diff options
| author | Sebastiaan van Stijn <github@gone.nl> | 2022-05-02 01:00:09 +0200 |
|---|---|---|
| committer | Sebastiaan van Stijn <github@gone.nl> | 2022-05-05 11:27:47 +0200 |
| commit | d733481399ff51815fb0742a74d2f1c222b4ac8d (patch) | |
| tree | 71b79689e6f89ea13e56550cf287da052e34750c /api/server | |
| parent | 521807837ba60247005f78f0000cfa1b30585c21 (diff) | |
| download | docker-d733481399ff51815fb0742a74d2f1c222b4ac8d.tar.gz | |
daemon: daemon.ContainerKill() accept stop-signal as string
This allows the postContainersKill() handler to pass values as-is. As part of
the rewrite, I also moved the daemon.GetContainer(name) call later in the
function, so that we can fail early if an invalid signal is passed, before
doing the (heavier) fetching of the container.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'api/server')
| -rw-r--r-- | api/server/router/container/backend.go | 2 | ||||
| -rw-r--r-- | api/server/router/container/container_routes.go | 13 |
2 files changed, 2 insertions, 13 deletions
diff --git a/api/server/router/container/backend.go b/api/server/router/container/backend.go index ca90112a34..6145c51de1 100644 --- a/api/server/router/container/backend.go +++ b/api/server/router/container/backend.go @@ -33,7 +33,7 @@ type copyBackend interface { // stateBackend includes functions to implement to provide container state lifecycle functionality. type stateBackend interface { ContainerCreate(config types.ContainerCreateConfig) (container.CreateResponse, error) - ContainerKill(name string, sig uint64) error + ContainerKill(name string, signal string) error ContainerPause(name string) error ContainerRename(oldName, newName string) error ContainerResize(name string, height, width int) error diff --git a/api/server/router/container/container_routes.go b/api/server/router/container/container_routes.go index cfa6838772..cc8ac09973 100644 --- a/api/server/router/container/container_routes.go +++ b/api/server/router/container/container_routes.go @@ -7,7 +7,6 @@ import ( "io" "net/http" "strconv" - "syscall" "github.com/containerd/containerd/platforms" "github.com/docker/docker/api/server/httpstatus" @@ -254,18 +253,8 @@ func (s *containerRouter) postContainersKill(ctx context.Context, w http.Respons return err } - var sig syscall.Signal name := vars["name"] - - // If we have a signal, look at it. Otherwise, do nothing - if sigStr := r.Form.Get("signal"); sigStr != "" { - var err error - if sig, err = signal.ParseSignal(sigStr); err != nil { - return errdefs.InvalidParameter(err) - } - } - - if err := s.backend.ContainerKill(name, uint64(sig)); err != nil { + if err := s.backend.ContainerKill(name, r.Form.Get("signal")); err != nil { var isStopped bool if errdefs.IsConflict(err) { isStopped = true |
