From 832ffce8331f6337f16843185a88df747c875410 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 14 Sep 2016 19:16:08 -0700 Subject: [PATCH] Improve error message for removing pre-defined (e.g., `ingress`) network This fix tries to address the issue raised in 24538 where the error message is unclear when removing pre-defined networks: ``` docker network rm ingress Error response from daemon: rpc error: code = 7 desc = 4vlxuzpk8bxdsxpyvkxluol5g is a pre-defined network and cannot be removed ``` This fix improve the error message so that if network's name is specified in the `RemoveNetwork`, then error message will contain the name and the ID (instead of just an ID): ``` docker network rm ingress Error response from daemon: rpc error: code = 7 desc = ingress (4vlxuzpk8bxdsxpyvkxluol5g) is a pre-defined network and cannot be removed ``` An integration test has been added to cover the changes. This fix fixes 24538. Signed-off-by: Yong Tang Upstream-commit: de4871165b43ec813940858a1c96ab6bb1fbd776 Component: engine --- .../engine/integration-cli/docker_cli_swarm_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/engine/integration-cli/docker_cli_swarm_test.go b/components/engine/integration-cli/docker_cli_swarm_test.go index f2cd007acc..306c55577e 100644 --- a/components/engine/integration-cli/docker_cli_swarm_test.go +++ b/components/engine/integration-cli/docker_cli_swarm_test.go @@ -264,3 +264,13 @@ func (s *DockerSwarmSuite) TestSwarmContainerAutoStart(c *check.C) { c.Assert(err, checker.IsNil) c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "") } + +func (s *DockerSwarmSuite) TestSwarmRemoveInternalNetwork(c *check.C) { + d := s.AddDaemon(c, true, true) + + name := "ingress" + out, err := d.Cmd("network", "rm", name) + c.Assert(err, checker.NotNil) + c.Assert(strings.TrimSpace(out), checker.Contains, name) + c.Assert(strings.TrimSpace(out), checker.Contains, "is a pre-defined network and cannot be removed") +}