Use entrypoint to detect weave router

This commit is contained in:
Bryan Boreham committed 2015-10-19 15:47:43 +00:00
1 parent 20ac0edda8
commit 697ee62d9a
2 files changed
+3 -2

No files matched your search

+1
View File
@@ -20,6 +20,7 @@ import (
var ( var (
containerIDRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/([^/]*)/.*") containerIDRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/([^/]*)/.*")
weaveWaitEntrypoint = []string{"/w/w"} weaveWaitEntrypoint = []string{"/w/w"}
weaveEntrypoint = "/home/weave/weaver"
) )
func callWeave(args ...string) ([]byte, []byte, error) { func callWeave(args ...string) ([]byte, []byte, error) {
+2 -2
View File
@@ -316,7 +316,7 @@ func containerShouldAttach(container *docker.Container) bool {
} }
func containerIsWeaveRouter(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) { 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 { 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"} args := []string{"attach-router"}
if _, stderr, err := callWeave(args...); err != nil { if _, stderr, err := callWeave(args...); err != nil {
Log.Warningf("Attaching container %s to weave network failed: %s", container.ID, string(stderr)) Log.Warningf("Attaching container %s to weave network failed: %s", container.ID, string(stderr))