From 23762e06396170ea4a5e77c799a1a8000f5c4020 Mon Sep 17 00:00:00 2001 From: David Wragg Date: Fri, 16 Oct 2015 20:55:44 +0100 Subject: [PATCH 1/2] Move repeated 'stop' code into functions --- weave | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/weave b/weave index 4e85fc9b..80a232fb 100755 --- a/weave +++ b/weave @@ -1385,6 +1385,11 @@ launch_router() { fi } +stop_router() { + stop $CONTAINER_NAME "Weave" + conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true +} + launch_proxy() { # Set WEAVEPROXY_DOCKER_ARGS in the environment in order to supply # additional parameters, such as resource limits, to docker @@ -1412,6 +1417,11 @@ launch_proxy() { wait_for_status $PROXY_CONTAINER_NAME http_call_unix $PROXY_CONTAINER_NAME status.sock } +stop_proxy() { + warn_if_stopping_proxy_in_env + stop $PROXY_CONTAINER_NAME "Proxy" +} + ########################################################################################## [ $(id -u) = 0 ] || { @@ -1767,20 +1777,16 @@ case "$COMMAND" in ;; stop) [ $# -eq 0 ] || usage - warn_if_stopping_proxy_in_env - stop $PROXY_CONTAINER_NAME "Proxy" - stop $CONTAINER_NAME "Weave" - conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true + stop_proxy + stop_router ;; stop-router) [ $# -eq 0 ] || usage - stop $CONTAINER_NAME "Weave" - conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true + stop_router ;; stop-proxy) [ $# -eq 0 ] || usage - warn_if_stopping_proxy_in_env - stop $PROXY_CONTAINER_NAME "Proxy" + stop_proxy ;; reset) [ $# -eq 0 ] || usage From 3482a7f1f1ac8f3c7b18df5dc374a13a88ef9122 Mon Sep 17 00:00:00 2001 From: David Wragg Date: Fri, 16 Oct 2015 16:49:12 +0100 Subject: [PATCH 2/2] Don't fail in launch-router if weave2 already exists And delete weave2 on stop-router. --- weave | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/weave b/weave index 80a232fb..b9d38f50 100755 --- a/weave +++ b/weave @@ -645,6 +645,8 @@ router_opts_bridge () { setup_router_iface_fastdp() { if [ -n "$WEAVE_PASSWORD" ] ; then # See router_opts_fastdp + # In case there is a lingering weave2 netdev + ip link del $ROUTER_HOSTNETNS_IFNAME >/dev/null 2>&1 || true connect_container_to_bridge $ROUTER_HOSTNETNS_IFNAME && ip link set $ROUTER_HOSTNETNS_IFNAME up fi @@ -1388,6 +1390,9 @@ launch_router() { stop_router() { stop $CONTAINER_NAME "Weave" conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true + # remove the weave2 netdev in a fastdp context + [ -d /sys/class/net/$BRIDGE -a ! -d /sys/class/net/$BRIDGE/bridge ] \ + && ip link del $ROUTER_HOSTNETNS_IFNAME >/dev/null 2>&1 || true } launch_proxy() {