From eb8889331259716a05f2d3552256dc4c70d66553 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 15 Aug 2017 13:45:38 +0000 Subject: [PATCH 1/4] Rename configureProxy to newProxyConfig --- prog/weaver/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prog/weaver/main.go b/prog/weaver/main.go index 0bdb6c3a..947fd1a8 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -210,7 +210,7 @@ func main() { mflag.StringVar(&pluginConfig.Socket, []string{"-plugin-socket"}, "/run/docker/plugins/weave.sock", "plugin socket on which to listen") mflag.StringVar(&pluginConfig.MeshSocket, []string{"-plugin-mesh-socket"}, "/run/docker/plugins/weavemesh.sock", "plugin socket on which to listen in mesh mode") - proxyConfig := configureProxy(version, defaultDockerHost) + proxyConfig := newProxyConfig(version, defaultDockerHost) if bridgeConfig.AWSVPC { proxyConfig.NoMulticastRoute = true proxyConfig.KeepTXOn = true @@ -525,7 +525,7 @@ func (nopPacketLogging) LogPacket(string, weave.PacketKey) { func (nopPacketLogging) LogForwardPacket(string, weave.ForwardPacketKey) { } -func configureProxy(version string, defaultDockerHost string) *weaveproxy.Config { +func newProxyConfig(version string, defaultDockerHost string) *weaveproxy.Config { proxyConfig := weaveproxy.Config{ Version: version, Image: getenvOrDefault("EXEC_IMAGE", "weaveworks/weaveexec"), From e251bfe8072a896beccedc7cb692879dd6fcc015 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 15 Aug 2017 13:46:26 +0000 Subject: [PATCH 2/4] Move use of command-line params to after we know them --- prog/weaver/main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/prog/weaver/main.go b/prog/weaver/main.go index 947fd1a8..09d61994 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -211,10 +211,6 @@ func main() { mflag.StringVar(&pluginConfig.MeshSocket, []string{"-plugin-mesh-socket"}, "/run/docker/plugins/weavemesh.sock", "plugin socket on which to listen in mesh mode") proxyConfig := newProxyConfig(version, defaultDockerHost) - if bridgeConfig.AWSVPC { - proxyConfig.NoMulticastRoute = true - proxyConfig.KeepTXOn = true - } // crude way of detecting that we probably have been started in a // container, with `weave launch` --> suppress misleading paths in @@ -231,6 +227,11 @@ func main() { os.Exit(0) } + if bridgeConfig.AWSVPC { + proxyConfig.NoMulticastRoute = true + proxyConfig.KeepTXOn = true + } + peers = mflag.Args() if resume && len(peers) > 0 { Log.Fatalf("You must not specify an initial peer list in conjunction with --resume") From 98b002f7c0f6bd3b9da83f6f94e77a8578152353 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 15 Aug 2017 13:48:33 +0000 Subject: [PATCH 3/4] Remove unnecessary 'Version' in proxy --- prog/weaver/main.go | 5 ++--- proxy/proxy.go | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/prog/weaver/main.go b/prog/weaver/main.go index 09d61994..cdf0810b 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -210,7 +210,7 @@ func main() { mflag.StringVar(&pluginConfig.Socket, []string{"-plugin-socket"}, "/run/docker/plugins/weave.sock", "plugin socket on which to listen") mflag.StringVar(&pluginConfig.MeshSocket, []string{"-plugin-mesh-socket"}, "/run/docker/plugins/weavemesh.sock", "plugin socket on which to listen in mesh mode") - proxyConfig := newProxyConfig(version, defaultDockerHost) + proxyConfig := newProxyConfig(defaultDockerHost) // crude way of detecting that we probably have been started in a // container, with `weave launch` --> suppress misleading paths in @@ -526,9 +526,8 @@ func (nopPacketLogging) LogPacket(string, weave.PacketKey) { func (nopPacketLogging) LogForwardPacket(string, weave.ForwardPacketKey) { } -func newProxyConfig(version string, defaultDockerHost string) *weaveproxy.Config { +func newProxyConfig(defaultDockerHost string) *weaveproxy.Config { proxyConfig := weaveproxy.Config{ - Version: version, Image: getenvOrDefault("EXEC_IMAGE", "weaveworks/weaveexec"), DockerBridge: getenvOrDefault("DOCKER_BRIDGE", "docker0"), DockerHost: defaultDockerHost, diff --git a/proxy/proxy.go b/proxy/proxy.go index 893168bc..199ae0f9 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -60,7 +60,6 @@ type Config struct { NoDefaultIPAM bool NoRewriteHosts bool TLSConfig TLSConfig - Version string WithoutDNS bool NoMulticastRoute bool KeepTXOn bool From a02fb753df8211c711a921f6198e7a89ae81fe0f Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 15 Aug 2017 13:49:20 +0000 Subject: [PATCH 4/4] Use the configured Docker host for the proxy, not the default one --- prog/weaver/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/prog/weaver/main.go b/prog/weaver/main.go index cdf0810b..eab5600b 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -210,7 +210,7 @@ func main() { mflag.StringVar(&pluginConfig.Socket, []string{"-plugin-socket"}, "/run/docker/plugins/weave.sock", "plugin socket on which to listen") mflag.StringVar(&pluginConfig.MeshSocket, []string{"-plugin-mesh-socket"}, "/run/docker/plugins/weavemesh.sock", "plugin socket on which to listen in mesh mode") - proxyConfig := newProxyConfig(defaultDockerHost) + proxyConfig := newProxyConfig() // crude way of detecting that we probably have been started in a // container, with `weave launch` --> suppress misleading paths in @@ -227,6 +227,7 @@ func main() { os.Exit(0) } + proxyConfig.DockerHost = dockerAPI if bridgeConfig.AWSVPC { proxyConfig.NoMulticastRoute = true proxyConfig.KeepTXOn = true @@ -526,11 +527,10 @@ func (nopPacketLogging) LogPacket(string, weave.PacketKey) { func (nopPacketLogging) LogForwardPacket(string, weave.ForwardPacketKey) { } -func newProxyConfig(defaultDockerHost string) *weaveproxy.Config { +func newProxyConfig() *weaveproxy.Config { proxyConfig := weaveproxy.Config{ Image: getenvOrDefault("EXEC_IMAGE", "weaveworks/weaveexec"), DockerBridge: getenvOrDefault("DOCKER_BRIDGE", "docker0"), - DockerHost: defaultDockerHost, } mflag.BoolVar(&proxyConfig.Enabled, []string{"-proxy"}, false, "instruct Weave Net to start its Docker proxy") mflagext.ListVar(&proxyConfig.ListenAddrs, []string{"H"}, nil, "addresses on which to listen for Docker proxy")