Browse code

Do not check and return strconv.Atoi error in api container restart, regression

Signed-off-by: Antonio Murdaca <me@runcom.ninja>

Antonio Murdaca authored on 2015/05/07 08:49:16
Showing 2 changed files
... ...
@@ -917,10 +917,7 @@ func (s *Server) postContainersRestart(version version.Version, w http.ResponseW
917 917
 		return fmt.Errorf("Missing parameter")
918 918
 	}
919 919
 
920
-	timeout, err := strconv.Atoi(r.Form.Get("t"))
921
-	if err != nil {
922
-		return err
923
-	}
920
+	timeout, _ := strconv.Atoi(r.Form.Get("t"))
924 921
 
925 922
 	if err := s.daemon.ContainerRestart(vars["name"], timeout); err != nil {
926 923
 		return err
... ...
@@ -899,6 +899,25 @@ func (s *DockerSuite) TestContainerApiRestart(c *check.C) {
899 899
 	}
900 900
 }
901 901
 
902
+func (s *DockerSuite) TestContainerApiRestartNotimeoutParam(c *check.C) {
903
+	name := "test-api-restart-no-timeout-param"
904
+	runCmd := exec.Command(dockerBinary, "run", "-di", "--name", name, "busybox", "top")
905
+	out, _, err := runCommandWithOutput(runCmd)
906
+	if err != nil {
907
+		c.Fatalf("Error on container creation: %v, output: %q", err, out)
908
+	}
909
+	id := strings.TrimSpace(out)
910
+	c.Assert(waitRun(id), check.IsNil)
911
+
912
+	status, _, err := sockRequest("POST", "/containers/"+name+"/restart", nil)
913
+	c.Assert(status, check.Equals, http.StatusNoContent)
914
+	c.Assert(err, check.IsNil)
915
+
916
+	if err := waitInspect(name, "{{ .State.Restarting  }} {{ .State.Running  }}", "false true", 5); err != nil {
917
+		c.Fatal(err)
918
+	}
919
+}
920
+
902 921
 func (s *DockerSuite) TestContainerApiStart(c *check.C) {
903 922
 	name := "testing-start"
904 923
 	config := map[string]interface{}{