diff --git a/proxy/create_exec_interceptor.go b/proxy/create_exec_interceptor.go index 5414346e9b..3a1af205e0 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 7376a70dca..ae218a73c2 100755 --- a/test/610_proxy_wait_for_weave_test.sh +++ b/test/610_proxy_wait_for_weave_test.sh @@ -7,7 +7,7 @@ entrypoint() { } start_suite "Proxy waits for weave to be ready before running container commands" -weave_on $HOST1 launch-proxy +weave_on $HOST1 launch BASE_IMAGE=busybox # Ensure the base image does not exist, so that it will be pulled ! docker_on $HOST1 inspect --format=" " $BASE_IMAGE >/dev/null 2>&1 || docker_on $HOST1 rmi $BASE_IMAGE @@ -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