From e52abafc48b9967984087c49f39be2479ae60693 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sat, 20 Feb 2016 10:59:47 +0000 Subject: [PATCH 1/3] treat restarting containers as "not running" thus preventing stale DNS & IPAM entries. Fixes #1977 --- common/docker/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/docker/client.go b/common/docker/client.go index 86cb9dd7..dabf3aec 100644 --- a/common/docker/client.go +++ b/common/docker/client.go @@ -97,7 +97,7 @@ func (c *Client) AddObserver(ob ContainerObserver) error { func (c *Client) IsContainerNotRunning(idStr string) bool { container, err := c.InspectContainer(idStr) if err == nil { - return !container.State.Running + return !container.State.Running || container.State.Restarting } if _, notThere := err.(*docker.NoSuchContainer); notThere { return true From 4a7157959a318cf07d38fed0c7e87e3077c78248 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sat, 20 Feb 2016 11:00:04 +0000 Subject: [PATCH 2/3] don't attempt to attach 'restarting' containers this is an optimisation... there is no point attempting to attach a 'restarting' container - it will fail. When the container *actually* restarts we'll get a 'Start' event, and attach at that point. Also, there is no point checking for 'Paused' since 'Paused' -> 'Running'. --- proxy/proxy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index 9dfb7972..c316c1cb 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -132,7 +132,7 @@ func (proxy *Proxy) AttachExistingContainers() { } continue } - if containerShouldAttach(container) && (container.State.Running || container.State.Paused) { + if containerShouldAttach(container) && container.State.Running && !container.State.Restarting { proxy.attach(container, false) } } From 6a9f9f66dc63adf18cf9197a0d55294cfd26c17a Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Tue, 23 Feb 2016 13:20:22 +0000 Subject: [PATCH 3/3] don't check for 'Restarting' when attaching on startup It is overkill. --- proxy/proxy.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index c316c1cb..5225b189 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -132,7 +132,8 @@ func (proxy *Proxy) AttachExistingContainers() { } continue } - if containerShouldAttach(container) && container.State.Running && !container.State.Restarting { + // The 'Running' check is purely an optimisation. + if containerShouldAttach(container) && container.State.Running { proxy.attach(container, false) } }