From 01b86d612cba22602509b436aad36d41135f14ce Mon Sep 17 00:00:00 2001 From: Wen Cheng Ma Date: Thu, 19 Nov 2015 13:51:26 +0800 Subject: [PATCH] Update docs and test of exec create api return codes Fixes issue #18054 Signed-off-by: Wen Cheng Ma --- daemon/exec.go | 2 +- docs/reference/api/docker_remote_api_v1.21.md | 4 +++- docs/reference/api/docker_remote_api_v1.22.md | 4 +++- integration-cli/docker_api_exec_test.go | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/daemon/exec.go b/daemon/exec.go index 73f76172de..9387b6dcee 100644 --- a/daemon/exec.go +++ b/daemon/exec.go @@ -108,7 +108,7 @@ func (d *Daemon) getExecConfig(name string) (*ExecConfig, error) { ec := d.execCommands.Get(name) // If the exec is found but its container is not in the daemon's list of - // containers then it must have been delete, in which case instead of + // containers then it must have been deleted, in which case instead of // saying the container isn't running, we should return a 404 so that // the user sees the same error now that they will after the // 5 minute clean-up loop is run which erases old/dead execs. diff --git a/docs/reference/api/docker_remote_api_v1.21.md b/docs/reference/api/docker_remote_api_v1.21.md index c57edc9e71..9a915fb060 100644 --- a/docs/reference/api/docker_remote_api_v1.21.md +++ b/docs/reference/api/docker_remote_api_v1.21.md @@ -2256,6 +2256,8 @@ Status Codes: - **201** – no error - **404** – no such container +- **409** - container is paused +- **500** - server error ### Exec Start @@ -2291,7 +2293,7 @@ Status Codes: - **200** – no error - **404** – no such exec instance -- **409** - container is stopped or paused +- **409** - container is paused **Stream details**: Similar to the stream behavior of `POST /container/(id)/attach` API diff --git a/docs/reference/api/docker_remote_api_v1.22.md b/docs/reference/api/docker_remote_api_v1.22.md index fee0842966..53bcaacaac 100644 --- a/docs/reference/api/docker_remote_api_v1.22.md +++ b/docs/reference/api/docker_remote_api_v1.22.md @@ -2263,6 +2263,8 @@ Status Codes: - **201** – no error - **404** – no such container +- **409** - container is paused +- **500** - server error ### Exec Start @@ -2298,7 +2300,7 @@ Status Codes: - **200** – no error - **404** – no such exec instance -- **409** - container is stopped or paused +- **409** - container is paused **Stream details**: Similar to the stream behavior of `POST /container/(id)/attach` API diff --git a/integration-cli/docker_api_exec_test.go b/integration-cli/docker_api_exec_test.go index 2483e6f39b..e5f2a96ead 100644 --- a/integration-cli/docker_api_exec_test.go +++ b/integration-cli/docker_api_exec_test.go @@ -49,6 +49,21 @@ func (s *DockerSuite) TestExecApiCreateNoValidContentType(c *check.C) { } } +func (s *DockerSuite) TestExecApiCreateContainerPaused(c *check.C) { + testRequires(c, DaemonIsLinux) + name := "exec_create_test" + dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") + + dockerCmd(c, "pause", name) + status, body, err := sockRequest("POST", fmt.Sprintf("/containers/%s/exec", name), map[string]interface{}{"Cmd": []string{"true"}}) + c.Assert(err, check.IsNil) + c.Assert(status, check.Equals, http.StatusConflict) + + if !bytes.Contains(body, []byte("Container "+name+" is paused, unpause the container before exec")) { + c.Fatalf("Expected message when creating exec command with Container %s is paused", name) + } +} + func (s *DockerSuite) TestExecAPIStart(c *check.C) { dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top")