From b5728796914a407dcb3c85aaa93978d9a3d718ff Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Tue, 28 Nov 2017 13:06:03 +0100 Subject: [PATCH 1/2] Add link to futur 1.5 documentation. --- docs/archive.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/archive.md b/docs/archive.md index 166815b3d..64dd4b783 100644 --- a/docs/archive.md +++ b/docs/archive.md @@ -1,9 +1,15 @@ -## Previous documentation +## Current versions documentation - [Latest stable](https://docs.traefik.io) - [Experimental](https://master--traefik-docs.netlify.com/) +## Future version documentation + +- [v1.5 RC](http://v1-5.archive.docs.traefik.io/) + +## Previous versions documentation + - [v1.4 aka Roquefort](http://v1-4.archive.docs.traefik.io/) - [v1.3 aka Raclette](http://v1-3.archive.docs.traefik.io/) @@ -14,4 +20,4 @@ ## More -[Change log](https://github.com/containous/traefik/blob/master/CHANGELOG.md) \ No newline at end of file +[Change log](https://github.com/containous/traefik/blob/master/CHANGELOG.md) From 47a5cfbd3eb829cc821299514130d56cb926ae08 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 28 Nov 2017 13:58:04 +0100 Subject: [PATCH 2/2] Fix empty ip when container is stopped --- integration/docker_test.go | 63 +++++++++++++++++++++++++ integration/fixtures/docker/simple.toml | 2 + provider/docker/docker.go | 8 +++- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/integration/docker_test.go b/integration/docker_test.go index 589405502..195cafe30 100644 --- a/integration/docker_test.go +++ b/integration/docker_test.go @@ -49,6 +49,14 @@ func (s *DockerSuite) startContainerWithLabels(c *check.C, image string, labels }) } +func (s *DockerSuite) startContainerWithNameAndLabels(c *check.C, name string, image string, labels map[string]string, args ...string) string { + return s.startContainerWithConfig(c, image, d.ContainerConfig{ + Name: name, + Cmd: args, + Labels: labels, + }) +} + func (s *DockerSuite) startContainerWithConfig(c *check.C, image string, config d.ContainerConfig) string { if config.Name == "" { config.Name = namesgenerator.GetRandomName(10) @@ -60,6 +68,11 @@ func (s *DockerSuite) startContainerWithConfig(c *check.C, image string, config return strings.SplitAfter(container.Name, "/")[1] } +func (s *DockerSuite) stopAndRemoveContainerByName(c *check.C, name string) { + s.project.Stop(c, name) + s.project.Remove(c, name) +} + func (s *DockerSuite) SetUpSuite(c *check.C) { project := docker.NewProjectFromEnv(c) s.project = project @@ -229,3 +242,53 @@ func (s *DockerSuite) TestDockerContainersWithServiceLabels(c *check.C) { c.Assert(json.Unmarshal(body, &version), checker.IsNil) c.Assert(version["Version"], checker.Equals, "swarm/1.0.0") } + +func (s *DockerSuite) TestRestartDockerContainers(c *check.C) { + file := s.adaptFileForHost(c, "fixtures/docker/simple.toml") + defer os.Remove(file) + // Start a container with some labels + labels := map[string]string{ + types.LabelPrefix + "frontend.rule": "Host:my.super.host", + types.LabelPort: "2375", + } + s.startContainerWithNameAndLabels(c, "powpow", "swarm:1.0.0", labels, "manage", "token://blabla") + + // Start traefik + cmd, display := s.traefikCmd(withConfigFile(file)) + defer display(c) + err := cmd.Start() + c.Assert(err, checker.IsNil) + defer cmd.Process.Kill() + + req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/version", nil) + c.Assert(err, checker.IsNil) + req.Host = "my.super.host" + + // FIXME Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?) + resp, err := try.ResponseUntilStatusCode(req, 1500*time.Millisecond, http.StatusOK) + c.Assert(err, checker.IsNil) + + body, err := ioutil.ReadAll(resp.Body) + c.Assert(err, checker.IsNil) + + var version map[string]interface{} + + c.Assert(json.Unmarshal(body, &version), checker.IsNil) + c.Assert(version["Version"], checker.Equals, "swarm/1.0.0") + + err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/backends", 60*time.Second, try.BodyContains("powpow")) + c.Assert(err, checker.IsNil) + + s.stopAndRemoveContainerByName(c, "powpow") + defer s.project.Remove(c, "powpow") + + time.Sleep(5 * time.Second) + + err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/backends", 10*time.Second, try.BodyContains("powpow")) + c.Assert(err, checker.NotNil) + + s.startContainerWithNameAndLabels(c, "powpow", "swarm:1.0.0", labels, "manage", "token://blabla") + + err = try.GetRequest("http://127.0.0.1:8080/api/providers/docker/backends", 60*time.Second, try.BodyContains("powpow")) + c.Assert(err, checker.IsNil) +} diff --git a/integration/fixtures/docker/simple.toml b/integration/fixtures/docker/simple.toml index 14ec46557..804c6f3cc 100644 --- a/integration/fixtures/docker/simple.toml +++ b/integration/fixtures/docker/simple.toml @@ -6,6 +6,8 @@ logLevel = "DEBUG" [entryPoints.http] address = ":8000" +[web] + [docker] # It's dynamagic ! diff --git a/provider/docker/docker.go b/provider/docker/docker.go index a8b65ea99..34a60a2f3 100644 --- a/provider/docker/docker.go +++ b/provider/docker/docker.go @@ -835,8 +835,12 @@ func listContainers(ctx context.Context, dockerClient client.ContainerAPIClient) if err != nil { log.Warnf("Failed to inspect container %s, error: %s", container.ID, err) } else { - dockerData := parseContainer(containerInspected) - containersInspected = append(containersInspected, dockerData) + // This condition is here to avoid to have empty IP https://github.com/containous/traefik/issues/2459 + // We register only container which are running + if containerInspected.ContainerJSONBase != nil && containerInspected.ContainerJSONBase.State != nil && containerInspected.ContainerJSONBase.State.Running { + dockerData := parseContainer(containerInspected) + containersInspected = append(containersInspected, dockerData) + } } } return containersInspected, nil