From c424c8c32c86d5e02964ad84802e9f9fa4e55522 Mon Sep 17 00:00:00 2001 From: Wen Cheng Ma Date: Fri, 4 Dec 2015 15:00:08 +0800 Subject: [PATCH] Correct the message of ErrorCodeNoSuchContainer to "No such container" Fixes issue #18424 Signed-off-by: Wen Cheng Ma --- api/server/router/container/container_routes.go | 2 +- api/server/router/container/copy.go | 2 +- errors/daemon.go | 2 +- integration-cli/docker_api_attach_test.go | 4 ++-- integration-cli/docker_api_containers_test.go | 2 +- integration-cli/docker_cli_logs_test.go | 2 +- integration-cli/docker_cli_stats_test.go | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/server/router/container/container_routes.go b/api/server/router/container/container_routes.go index a766535b1a..a52c03d369 100644 --- a/api/server/router/container/container_routes.go +++ b/api/server/router/container/container_routes.go @@ -367,7 +367,7 @@ func (s *containerRouter) deleteContainers(ctx context.Context, w http.ResponseW if err := s.backend.ContainerRm(name, config); err != nil { // Force a 404 for the empty string if strings.Contains(strings.ToLower(err.Error()), "prefix can't be empty") { - return fmt.Errorf("no such id: \"\"") + return fmt.Errorf("no such container: \"\"") } return err } diff --git a/api/server/router/container/copy.go b/api/server/router/container/copy.go index 12a4a3c493..4f04f94a3c 100644 --- a/api/server/router/container/copy.go +++ b/api/server/router/container/copy.go @@ -31,7 +31,7 @@ func (s *containerRouter) postContainersCopy(ctx context.Context, w http.Respons data, err := s.backend.ContainerCopy(vars["name"], cfg.Resource) if err != nil { - if strings.Contains(strings.ToLower(err.Error()), "no such id") { + if strings.Contains(strings.ToLower(err.Error()), "no such container") { w.WriteHeader(http.StatusNotFound) return nil } diff --git a/errors/daemon.go b/errors/daemon.go index 0ae089f214..21fed03050 100644 --- a/errors/daemon.go +++ b/errors/daemon.go @@ -14,7 +14,7 @@ var ( // name or ID and we can't find it. ErrorCodeNoSuchContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{ Value: "NOSUCHCONTAINER", - Message: "no such id: %s", + Message: "No such container: %s", Description: "The specified container can not be found", HTTPStatusCode: http.StatusNotFound, }) diff --git a/integration-cli/docker_api_attach_test.go b/integration-cli/docker_api_attach_test.go index 32bf4b7f33..6c3e36440b 100644 --- a/integration-cli/docker_api_attach_test.go +++ b/integration-cli/docker_api_attach_test.go @@ -70,7 +70,7 @@ func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *check.C) { status, body, err := sockRequest("POST", "/containers/doesnotexist/attach", nil) c.Assert(status, checker.Equals, http.StatusNotFound) c.Assert(err, checker.IsNil) - expected := "no such id: doesnotexist\n" + expected := "No such container: doesnotexist\n" c.Assert(string(body), checker.Contains, expected) } @@ -78,7 +78,7 @@ func (s *DockerSuite) TestGetContainersWsAttachContainerNotFound(c *check.C) { status, body, err := sockRequest("GET", "/containers/doesnotexist/attach/ws", nil) c.Assert(status, checker.Equals, http.StatusNotFound) c.Assert(err, checker.IsNil) - expected := "no such id: doesnotexist\n" + expected := "No such container: doesnotexist\n" c.Assert(string(body), checker.Contains, expected) } diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index 9364429a62..11dfff8891 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -1051,7 +1051,7 @@ func (s *DockerSuite) TestContainerApiDeleteNotExist(c *check.C) { status, body, err := sockRequest("DELETE", "/containers/doesnotexist", nil) c.Assert(err, checker.IsNil) c.Assert(status, checker.Equals, http.StatusNotFound) - c.Assert(string(body), checker.Matches, "no such id: doesnotexist\n") + c.Assert(string(body), checker.Matches, "No such container: doesnotexist\n") } func (s *DockerSuite) TestContainerApiDeleteForce(c *check.C) { diff --git a/integration-cli/docker_cli_logs_test.go b/integration-cli/docker_cli_logs_test.go index e93a1aa93f..41780f8a41 100644 --- a/integration-cli/docker_cli_logs_test.go +++ b/integration-cli/docker_cli_logs_test.go @@ -348,6 +348,6 @@ func (s *DockerSuite) TestLogsFollowGoroutinesNoOutput(c *check.C) { func (s *DockerSuite) TestLogsCLIContainerNotFound(c *check.C) { name := "testlogsnocontainer" out, _, _ := dockerCmdWithError("logs", name) - message := fmt.Sprintf(".*no such id: %s.*\n", name) + message := fmt.Sprintf(".*No such container: %s.*\n", name) c.Assert(out, checker.Matches, message) } diff --git a/integration-cli/docker_cli_stats_test.go b/integration-cli/docker_cli_stats_test.go index 372e40b09c..6b866e14f8 100644 --- a/integration-cli/docker_cli_stats_test.go +++ b/integration-cli/docker_cli_stats_test.go @@ -44,11 +44,11 @@ func (s *DockerSuite) TestStatsContainerNotFound(c *check.C) { out, _, err := dockerCmdWithError("stats", "notfound") c.Assert(err, checker.NotNil) - c.Assert(out, checker.Contains, "no such id: notfound", check.Commentf("Expected to fail on not found container stats, got %q instead", out)) + c.Assert(out, checker.Contains, "No such container: notfound", check.Commentf("Expected to fail on not found container stats, got %q instead", out)) out, _, err = dockerCmdWithError("stats", "--no-stream", "notfound") c.Assert(err, checker.NotNil) - c.Assert(out, checker.Contains, "no such id: notfound", check.Commentf("Expected to fail on not found container stats with --no-stream, got %q instead", out)) + c.Assert(out, checker.Contains, "No such container: notfound", check.Commentf("Expected to fail on not found container stats with --no-stream, got %q instead", out)) } func (s *DockerSuite) TestStatsAllRunningNoStream(c *check.C) {