From ce25f58639490840ba2f6f1557a98004e9fa3bde Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Thu, 3 Dec 2015 15:09:23 +0000 Subject: [PATCH] `weave launch-proxy` accepts --no-multicast-route --- prog/weaveexec/Dockerfile | 2 ++ prog/weaveproxy/main.go | 1 + proxy/create_container_interceptor.go | 10 ++++++++-- proxy/proxy.go | 24 ++++++++++++++++-------- proxy/start_container_interceptor.go | 10 ++++++++-- weave | 1 + 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/prog/weaveexec/Dockerfile b/prog/weaveexec/Dockerfile index 2b44f344..f700f20a 100644 --- a/prog/weaveexec/Dockerfile +++ b/prog/weaveexec/Dockerfile @@ -6,6 +6,7 @@ LABEL works.weave.role=system WORKDIR /home/weave VOLUME /w VOLUME /w-noop +VOLUME /w-nomcast ENTRYPOINT ["/home/weave/sigproxy", "/home/weave/weave"] RUN apk add --update \ @@ -22,4 +23,5 @@ ADD ./weave ./sigproxy ./weaveproxy ./symlink /home/weave/ ADD ./netcheck ./docker_tls_args /usr/bin/ ADD ./weavewait /w/w ADD ./weavewait_noop /w-noop/w +ADD ./weavewait_nomcast /w-nomcast/w ADD ./docker.tgz / diff --git a/prog/weaveproxy/main.go b/prog/weaveproxy/main.go index 9db07cd5..6de9a8b4 100644 --- a/prog/weaveproxy/main.go +++ b/prog/weaveproxy/main.go @@ -40,6 +40,7 @@ func main() { mflag.BoolVar(&c.TLSConfig.Verify, []string{"#tlsverify", "-tlsverify"}, false, "Use TLS and verify the remote") mflag.BoolVar(&c.WithDNS, []string{"-with-dns", "w"}, false, "instruct created containers to always use weaveDNS as their nameserver") mflag.BoolVar(&c.WithoutDNS, []string{"-without-dns"}, false, "instruct created containers to never use weaveDNS as their nameserver") + mflag.BoolVar(&c.NoMulticastRoute, []string{"-no-multicast-route"}, false, "do not add a multicast route via the weave interface when attaching containers") mflag.Parse() if justVersion { diff --git a/proxy/create_container_interceptor.go b/proxy/create_container_interceptor.go index 7f4bc84e..b13d16f3 100644 --- a/proxy/create_container_interceptor.go +++ b/proxy/create_container_interceptor.go @@ -53,8 +53,14 @@ func (i *createContainerInterceptor) InterceptRequest(r *http.Request) error { Log.Infof("Leaving container alone because %s", err) } else { Log.Infof("Creating container with WEAVE_CIDR \"%s\"", strings.Join(cidrs, " ")) - if err := addVolume(hostConfig, i.proxy.weaveWaitVolume, "/w", "ro"); err != nil { - return err + if i.proxy.NoMulticastRoute { + if err := addVolume(hostConfig, i.proxy.weaveWaitNomcastVolume, "/w", "ro"); err != nil { + return err + } + } else { + if err := addVolume(hostConfig, i.proxy.weaveWaitVolume, "/w", "ro"); err != nil { + return err + } } if err := i.setWeaveWaitEntrypoint(container); err != nil { return err diff --git a/proxy/proxy.go b/proxy/proxy.go index bf14cb76..9c8b15f7 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -60,6 +60,7 @@ type Config struct { Version string WithDNS bool WithoutDNS bool + NoMulticastRoute bool } type wait struct { @@ -71,13 +72,14 @@ type wait struct { type Proxy struct { sync.Mutex Config - client *docker.Client - dockerBridgeIP string - hostnameMatchRegexp *regexp.Regexp - weaveWaitVolume string - weaveWaitNoopVolume string - normalisedAddrs []string - waiters map[*http.Request]*wait + client *docker.Client + dockerBridgeIP string + hostnameMatchRegexp *regexp.Regexp + weaveWaitVolume string + weaveWaitNoopVolume string + weaveWaitNomcastVolume string + normalisedAddrs []string + waiters map[*http.Request]*wait } func NewProxy(c Config) (*Proxy, error) { @@ -146,7 +148,10 @@ func (proxy *Proxy) findWeaveWaitVolumes() error { if proxy.weaveWaitVolume, err = proxy.findVolume("/w"); err != nil { return err } - proxy.weaveWaitNoopVolume, err = proxy.findVolume("/w-noop") + if proxy.weaveWaitNoopVolume, err = proxy.findVolume("/w-noop"); err != nil { + return err + } + proxy.weaveWaitNomcastVolume, err = proxy.findVolume("/w-nomcast") return err } @@ -430,6 +435,9 @@ func (proxy *Proxy) attach(container *docker.Container, orDie bool) error { } } } + if proxy.NoMulticastRoute { + args = append(args, "--no-multicast-route") + } if orDie { args = append(args, "--or-die") } diff --git a/proxy/start_container_interceptor.go b/proxy/start_container_interceptor.go index 6e68059e..678fbacf 100644 --- a/proxy/start_container_interceptor.go +++ b/proxy/start_container_interceptor.go @@ -41,8 +41,14 @@ func (i *startContainerInterceptor) InterceptRequest(r *http.Request) error { return err } } else { - if err := addVolume(hostConfig, i.proxy.weaveWaitVolume, "/w", "ro"); err != nil { - return err + if i.proxy.NoMulticastRoute { + if err := addVolume(hostConfig, i.proxy.weaveWaitNomcastVolume, "/w", "ro"); err != nil { + return err + } + } else { + if err := addVolume(hostConfig, i.proxy.weaveWaitVolume, "/w", "ro"); err != nil { + return err + } } if dnsDomain := i.proxy.getDNSDomain(); dnsDomain != "" { if err := i.proxy.setWeaveDNS(hostConfig, container.Config.Hostname, dnsDomain); err != nil { diff --git a/weave b/weave index cc4beb64..c9e7399d 100755 --- a/weave +++ b/weave @@ -48,6 +48,7 @@ weave launch-router [--password ] [--nickname ] [--no-discovery] [--init-peer-count ] ... weave launch-proxy [-H ] [--with-dns | --without-dns] [--no-default-ipalloc] [--no-rewrite-hosts] + [--no-multicast-route] [--hostname-from-label ] [--hostname-match ] [--hostname-replacement ]