Merge pull request #1303 from weaveworks/1302-proxy-net-none

[proxy] attach containers with --net=none to weave

Fixes #1302.
This commit is contained in:
Matthias Radestock committed 2015-08-14 14:03:36 +01:00
commit 9de7c9ed0d
2 files changed
+12 -13

No files matched your search

+6 -5
View File
@@ -225,11 +225,12 @@ func (proxy *Proxy) listen(protoAndAddr string) (net.Listener, string, error) {
} }
func (proxy *Proxy) weaveCIDRsFromConfig(config *docker.Config, hostConfig *docker.HostConfig) ([]string, error) { func (proxy *Proxy) weaveCIDRsFromConfig(config *docker.Config, hostConfig *docker.HostConfig) ([]string, error) {
if hostConfig != nil && netMode := ""
hostConfig.NetworkMode != "" && if hostConfig != nil {
hostConfig.NetworkMode != "default" && netMode = hostConfig.NetworkMode
hostConfig.NetworkMode != "bridge" { }
return nil, fmt.Errorf("--net option: %q", hostConfig.NetworkMode) if netMode == "host" || strings.HasPrefix(netMode, "container:") {
return nil, fmt.Errorf("--net option: %q", netMode)
} }
for _, e := range config.Env { for _, e := range config.Env {
if strings.HasPrefix(e, "WEAVE_CIDR=") { if strings.HasPrefix(e, "WEAVE_CIDR=") {
+6 -8
View File
@@ -20,18 +20,16 @@ proxy_start_container $HOST1 --name=auto
proxy_start_container $HOST1 --name=none -e WEAVE_CIDR=none proxy_start_container $HOST1 --name=none -e WEAVE_CIDR=none
proxy_start_container $HOST2 --name=zero -e WEAVE_CIDR= proxy_start_container $HOST2 --name=zero -e WEAVE_CIDR=
proxy_start_container $HOST2 --name=no-default proxy_start_container $HOST2 --name=no-default
proxy_start_container $HOST1 --name=nodocker --net=none
proxy_start_container $HOST1 --name=bridge --net=bridge proxy_start_container $HOST1 --name=bridge --net=bridge
proxy_start_container $HOST1 --name=host --net=host proxy_start_container $HOST1 --name=host --net=host
proxy_start_container $HOST1 --name=other --net=container:auto proxy_start_container $HOST1 --name=other --net=container:auto
AUTO=$(container_ip $HOST1 auto) assert_raises "proxy exec_on $HOST1 auto $PING $(container_ip $HOST2 zero)"
ZERO=$(container_ip $HOST2 zero) assert_raises "proxy exec_on $HOST2 zero $PING $(container_ip $HOST1 auto)"
BRIDGE=$(container_ip $HOST1 bridge) assert_raises "proxy exec_on $HOST2 zero $PING $(container_ip $HOST1 bridge)"
OTHER=$(container_ip $HOST1 other) assert_raises "proxy exec_on $HOST2 zero $PING $(container_ip $HOST1 other)"
assert_raises "proxy exec_on $HOST1 auto $PING $ZERO" assert_raises "proxy exec_on $HOST2 zero $PING $(container_ip $HOST1 nodocker)"
assert_raises "proxy exec_on $HOST2 zero $PING $AUTO"
assert_raises "proxy exec_on $HOST2 zero $PING $BRIDGE"
assert_raises "proxy exec_on $HOST2 zero $PING $OTHER"
assert_no_ethwe $HOST1 none assert_no_ethwe $HOST1 none
assert_no_ethwe $HOST2 no-default assert_no_ethwe $HOST2 no-default