Browse code

Merge pull request #18084 from wenchma/18054_exec_start_fix

Update docs and test of exec create api return codes

Alexander Morozov authored on 2015/11/20 06:51:46
Showing 4 changed files
... ...
@@ -108,7 +108,7 @@ func (d *Daemon) getExecConfig(name string) (*ExecConfig, error) {
108 108
 	ec := d.execCommands.Get(name)
109 109
 
110 110
 	// If the exec is found but its container is not in the daemon's list of
111
-	// containers then it must have been delete, in which case instead of
111
+	// containers then it must have been deleted, in which case instead of
112 112
 	// saying the container isn't running, we should return a 404 so that
113 113
 	// the user sees the same error now that they will after the
114 114
 	// 5 minute clean-up loop is run which erases old/dead execs.
... ...
@@ -2256,6 +2256,8 @@ Status Codes:
2256 2256
 
2257 2257
 -   **201** – no error
2258 2258
 -   **404** – no such container
2259
+-   **409** - container is paused
2260
+-   **500** - server error
2259 2261
 
2260 2262
 ### Exec Start
2261 2263
 
... ...
@@ -2291,7 +2293,7 @@ Status Codes:
2291 2291
 
2292 2292
 -   **200** – no error
2293 2293
 -   **404** – no such exec instance
2294
--   **409** - container is stopped or paused
2294
+-   **409** - container is paused
2295 2295
 
2296 2296
     **Stream details**:
2297 2297
     Similar to the stream behavior of `POST /container/(id)/attach` API
... ...
@@ -2263,6 +2263,8 @@ Status Codes:
2263 2263
 
2264 2264
 -   **201** – no error
2265 2265
 -   **404** – no such container
2266
+-   **409** - container is paused
2267
+-   **500** - server error
2266 2268
 
2267 2269
 ### Exec Start
2268 2270
 
... ...
@@ -2298,7 +2300,7 @@ Status Codes:
2298 2298
 
2299 2299
 -   **200** – no error
2300 2300
 -   **404** – no such exec instance
2301
--   **409** - container is stopped or paused
2301
+-   **409** - container is paused
2302 2302
 
2303 2303
     **Stream details**:
2304 2304
     Similar to the stream behavior of `POST /container/(id)/attach` API
... ...
@@ -49,6 +49,21 @@ func (s *DockerSuite) TestExecApiCreateNoValidContentType(c *check.C) {
49 49
 	}
50 50
 }
51 51
 
52
+func (s *DockerSuite) TestExecApiCreateContainerPaused(c *check.C) {
53
+	testRequires(c, DaemonIsLinux)
54
+	name := "exec_create_test"
55
+	dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh")
56
+
57
+	dockerCmd(c, "pause", name)
58
+	status, body, err := sockRequest("POST", fmt.Sprintf("/containers/%s/exec", name), map[string]interface{}{"Cmd": []string{"true"}})
59
+	c.Assert(err, check.IsNil)
60
+	c.Assert(status, check.Equals, http.StatusConflict)
61
+
62
+	if !bytes.Contains(body, []byte("Container "+name+" is paused, unpause the container before exec")) {
63
+		c.Fatalf("Expected message when creating exec command with Container %s is paused", name)
64
+	}
65
+}
66
+
52 67
 func (s *DockerSuite) TestExecAPIStart(c *check.C) {
53 68
 	dockerCmd(c, "run", "-d", "--name", "test", "busybox", "top")
54 69