From 9a17439e2fa4e88f0c0c34b9dfdf9b74a84c1880 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 2 Jun 2016 17:54:22 +0100 Subject: [PATCH] Warn on 'weave reset' if weave container is not running --- weave | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/weave b/weave index 90a319bc..53af6c0d 100755 --- a/weave +++ b/weave @@ -90,7 +90,7 @@ weave stop stop-proxy stop-plugin -weave reset +weave reset [--force] rmpeer ... @@ -2153,11 +2153,25 @@ EOF stop_plugin ;; reset) - [ $# -eq 0 ] || usage + [ $# -eq 0 ] || [ $# -eq 1 -a "$1" = "--force" ] || usage plugin_disabled || util_op remove-plugin-network weave || true warn_if_stopping_proxy_in_env - call_weave DELETE /peer >/dev/null 2>&1 || true - fractional_sleep 0.5 # Allow some time for broadcast updates to go out + res=0 + [ "$1" = "--force" ] || check_running $CONTAINER_NAME 2>/dev/null || res=$? + case $res in + 0) + call_weave DELETE /peer >/dev/null 2>&1 || true + fractional_sleep 0.5 # Allow some time for broadcast updates to go out + ;; + 1) + # No such container; assume user already did reset + ;; + 2) + echo "ERROR: weave is not running; unable to remove from cluster." >&2 + echo "Re-launch weave before reset or use --force to override." >&2 + exit 1 + ;; + esac for NAME in $PLUGIN_CONTAINER_NAME $CONTAINER_NAME $PROXY_CONTAINER_NAME ; do docker stop $NAME >/dev/null 2>&1 || true docker rm -f $NAME >/dev/null 2>&1 || true