diff --git a/test/610_proxy_wait_for_weave_test.sh b/test/610_proxy_wait_for_weave_test.sh index 7525d4e0..a89edaf7 100755 --- a/test/610_proxy_wait_for_weave_test.sh +++ b/test/610_proxy_wait_for_weave_test.sh @@ -6,15 +6,26 @@ entrypoint() { docker_on $HOST1 inspect --format="{{.Config.Entrypoint}}" "$@" } +check_iface_ready() { + assert_raises "proxy docker_on $HOST1 run -e 'WEAVE_CIDR=$1' $BASE_IMAGE $CHECK_ETHWE_UP" + assert_raises "proxy docker_on $HOST1 run -e 'WEAVE_CIDR=$1' $BASE_IMAGE ip -4 -o addr show ethwe | grep -q '$1'" +} + start_suite "Proxy waits for weave to be ready before running container commands" -weave_on $HOST1 launch-proxy + 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 -assert_raises "proxy docker_on $HOST1 run --name c1 -e 'WEAVE_CIDR=10.2.1.1/24' $BASE_IMAGE $CHECK_ETHWE_UP" +# check that interface is ready, with and without --no-multicast-route +weave_on $HOST1 launch-proxy --no-multicast-route +check_iface_ready 10.2.1.1/24 +weave_on $HOST1 stop-proxy +weave_on $HOST1 launch-proxy +check_iface_ready 10.2.1.1/24 # Check committed containers only have one weavewait prepended +proxy_start_container $HOST1 --name c1 -e 'WEAVE_CIDR=10.2.1.1/24' 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)" diff --git a/weave b/weave index 0bbf4faa..41a015b8 100755 --- a/weave +++ b/weave @@ -776,11 +776,11 @@ connect_container_to_bridge() { # veth pair in the 'up' or 'down' state. Furthermore, moving one # end into a netns normally sets them to 'down'. But, moving an # end into the default netns is a null operation, so they stay up, - # which leads to errors later on. So to get a consistent result, - # we have to be explicit in setting them 'up' or 'down' as - # necessary. + # which leads to errors in 'set name' since that requires the + # interface to be down. So to get a consistent result, we set the + # interface 'down' to begin with. if ! netnsenter ip link set $GUEST_IFNAME down || - ! netnsenter ip link set $GUEST_IFNAME name $1 up || + ! netnsenter ip link set $GUEST_IFNAME name $1 || ! ip link set $LOCAL_IFNAME up || ! add_iface_$BRIDGE_TYPE $LOCAL_IFNAME || ! configure_arp_cache $1 "netnsenter" ; then