From 697ee62d9a2ae8773c69064bcd2253f12c4da33c Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 16 Oct 2015 15:01:38 +0100 Subject: [PATCH] Use entrypoint to detect weave router --- proxy/common.go | 1 + proxy/proxy.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/proxy/common.go b/proxy/common.go index 3f41eb17..1dfe787e 100644 --- a/proxy/common.go +++ b/proxy/common.go @@ -20,6 +20,7 @@ import ( var ( containerIDRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/([^/]*)/.*") weaveWaitEntrypoint = []string{"/w/w"} + weaveEntrypoint = "/home/weave/weaver" ) func callWeave(args ...string) ([]byte, []byte, error) { diff --git a/proxy/proxy.go b/proxy/proxy.go index 77cc7ca9..171a91a0 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -316,7 +316,7 @@ func containerShouldAttach(container *docker.Container) bool { } func containerIsWeaveRouter(container *docker.Container) bool { - return strings.HasPrefix(container.Config.Image, "weaveworks/weave") + return len(container.Config.Entrypoint) > 0 && container.Config.Entrypoint[0] == weaveEntrypoint } func (proxy *Proxy) createWait(r *http.Request, ident string) { @@ -393,7 +393,7 @@ func (proxy *Proxy) attach(container *docker.Container, orDie bool) error { } func (proxy *Proxy) attachRouter(container *docker.Container) error { - Log.Infof("Attaching weave router container") + Log.Infof("Attaching weave router container:", container.ID) args := []string{"attach-router"} if _, stderr, err := callWeave(args...); err != nil { Log.Warningf("Attaching container %s to weave network failed: %s", container.ID, string(stderr))