diff --git a/proxy/create_exec_interceptor.go b/proxy/create_exec_interceptor.go index 72e62730..33e655d9 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 { Info.Printf("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 49d023e9..204f86cc 100755 --- a/test/610_proxy_wait_for_weave_test.sh +++ b/test/610_proxy_wait_for_weave_test.sh @@ -21,4 +21,8 @@ COMMITTED_IMAGE=$(proxy docker_on $HOST1 commit c1) assert_raises "proxy docker_on $HOST1 run --name c2 $COMMITTED_IMAGE" assert "entrypoint c2" "$(entrypoint $COMMITTED_IMAGE)" +# 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