diff --git a/proxy/create_exec_interceptor.go b/proxy/create_exec_interceptor.go index 5414346e..3a1af205 100644 --- a/proxy/create_exec_interceptor.go +++ b/proxy/create_exec_interceptor.go @@ -29,7 +29,9 @@ func (i *createExecInterceptor) InterceptRequest(r *http.Request) error { return err } - if cidrs, ok := i.proxy.weaveCIDRsFromConfig(container.Config); ok { + _, hasWeaveWait := container.Volumes["/w"] + cidrs, hasCIDRs := i.proxy.weaveCIDRsFromConfig(container.Config) + if hasCIDRs && hasWeaveWait { Log.Infof("Exec in container %s with WEAVE_CIDR \"%s\"", container.ID, strings.Join(cidrs, " ")) cmd := append(weaveWaitEntrypoint, "-s") options.Cmd = append(cmd, options.Cmd...) diff --git a/test/610_proxy_wait_for_weave_test.sh b/test/610_proxy_wait_for_weave_test.sh index 7376a70d..b91451f4 100755 --- a/test/610_proxy_wait_for_weave_test.sh +++ b/test/610_proxy_wait_for_weave_test.sh @@ -22,4 +22,8 @@ assert "entrypoint c2" "$(entrypoint $COMMITTED_IMAGE)" # Check weave IP is first ip returned, so java (etc) prefer weave. assert "proxy docker_on $HOST1 run -e 'WEAVE_CIDR=10.2.1.1/24' $BASE_IMAGE hostname -i | cut -d' ' -f1" "10.2.1.1" +# Check exec works on containers without weavewait +docker_on $HOST1 run -dit --name c3 $SMALL_IMAGE /bin/sh +assert_raises "proxy docker_on $HOST1 exec c3 true" + end_suite