From 7d2227c5a4707b1e0aa51483f88907a2c238f898 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 22 Dec 2015 10:50:02 +0000 Subject: [PATCH 1/5] Add plugin version to 'weave version' --- weave | 1 + 1 file changed, 1 insertion(+) diff --git a/weave b/weave index 21950e60..f824344a 100755 --- a/weave +++ b/weave @@ -1829,6 +1829,7 @@ case "$COMMAND" in [ $# -eq 0 ] || usage ask_version $CONTAINER_NAME $IMAGE || true ask_version $PROXY_CONTAINER_NAME $EXEC_IMAGE --entrypoint=/home/weave/weaveproxy || true + ask_version $PLUGIN_CONTAINER_NAME $PLUGIN_IMAGE || true ;; # intentionally undocumented since it assumes knowledge of weave # internals From 3ade796e8d18a9d4253ce464463dd94114300052 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Tue, 22 Dec 2015 12:30:53 +0000 Subject: [PATCH 2/5] don't launch anything when plugin is running ...just as we don't launch anything if either the router or proxy are running. Fixes #1818. --- weave | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/weave b/weave index 21950e60..27a6d746 100755 --- a/weave +++ b/weave @@ -1850,15 +1850,13 @@ EOF ;; launch) deprecation_warnings "$@" - check_not_running $CONTAINER_NAME $BASE_IMAGE - check_not_running $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE + check_not_running $CONTAINER_NAME $BASE_IMAGE + check_not_running $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE + check_not_running $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE COMMON_ARGS=$(common_launch_args "$@") launch_router "$@" launch_proxy $COMMON_ARGS - if [ -z $WEAVE_NO_PLUGIN ] && check_docker_server_api_version 1.21 ; then - check_not_running $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE - launch_plugin $COMMON_ARGS - fi + [ -z $WEAVE_NO_PLUGIN ] && check_docker_server_api_version 1.21 && launch_plugin $COMMON_ARGS ;; launch-router) deprecation_warnings "$@" From 73e0a6bb0acb74e0c63fbfade0be5b40aca989d9 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 15 Dec 2015 15:35:20 +0000 Subject: [PATCH 3/5] Inform user about weave containers in state 'restarting' --- weave | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/weave b/weave index 92177ed0..b9ea347c 100755 --- a/weave +++ b/weave @@ -906,29 +906,37 @@ container_weave_addrs() { # functions for interacting with containers ###################################################################### -# Check that a container named $1 with image $2 is not running +# Check that a container for component $1 named $2 with image $3 is not running check_not_running() { - case $(docker inspect --format='{{.State.Running}} {{.Config.Image}}' $1 2>/dev/null) in - "true $2") - echo "$1 is already running." >&2 + case $(docker inspect --format='{{.State.Running}} {{.State.Status}} {{.Config.Image}}' $2 2>/dev/null) in + "true restarting $3") + echo "$2 is restarting; you can stop it with 'weave stop-$1'." >&2 exit 1 ;; - "true $2:"*) - echo "$1 is already running." >&2 + "true restarting $3:"*) + echo "$2 is restarting; you can stop it with 'weave stop-$1'." >&2 exit 1 ;; - "false $2") - docker rm $1 >/dev/null + "true "*" $3") + echo "$2 is already running." >&2 + exit 1 ;; - "false $2:"*) - docker rm $1 >/dev/null + "true "*" $3:"*) + echo "$2 is already running." >&2 + exit 1 + ;; + "false "*" $3") + docker rm $2 >/dev/null + ;; + "false "*" $3:"*) + docker rm $2 >/dev/null ;; true*) - echo "Found another running container named '$1'. Aborting." >&2 + echo "Found another running container named '$2'. Aborting." >&2 exit 1 ;; false*) - echo "Found another container named '$1'. Aborting." >&2 + echo "Found another container named '$2'. Aborting." >&2 exit 1 ;; esac @@ -1843,9 +1851,9 @@ EOF ;; launch) deprecation_warnings "$@" - check_not_running $CONTAINER_NAME $BASE_IMAGE - check_not_running $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE - check_not_running $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE + check_not_running router $CONTAINER_NAME $BASE_IMAGE + check_not_running proxy $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE + check_not_running plugin $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE COMMON_ARGS=$(common_launch_args "$@") launch_router "$@" launch_proxy $COMMON_ARGS @@ -1853,7 +1861,7 @@ EOF ;; launch-router) deprecation_warnings "$@" - check_not_running $CONTAINER_NAME $BASE_IMAGE + check_not_running router $CONTAINER_NAME $BASE_IMAGE launch_router "$@" echo $ROUTER_CONTAINER ;; @@ -1867,12 +1875,12 @@ EOF ;; launch-proxy) deprecation_warnings "$@" - check_not_running $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE + check_not_running proxy $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE launch_proxy "$@" echo $PROXY_CONTAINER ;; launch-plugin) - check_not_running $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE + check_not_running plugin $PLUGIN_CONTAINER_NAME $BASE_PLUGIN_IMAGE launch_plugin "$@" echo $PLUGIN_CONTAINER ;; From 0c2aa494ae6848fc9c2f7336a78d8bd9a354dd1e Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 22 Dec 2015 11:48:09 +0000 Subject: [PATCH 4/5] Reduce duplication --- weave | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/weave b/weave index b9ea347c..90a78011 100755 --- a/weave +++ b/weave @@ -908,29 +908,19 @@ container_weave_addrs() { # Check that a container for component $1 named $2 with image $3 is not running check_not_running() { - case $(docker inspect --format='{{.State.Running}} {{.State.Status}} {{.Config.Image}}' $2 2>/dev/null) in + RUN_STATUS=$(docker inspect --format='{{.State.Running}} {{.State.Status}} {{.Config.Image}}' $2 2>/dev/null) || true + case ${RUN_STATUS%:*} in "true restarting $3") echo "$2 is restarting; you can stop it with 'weave stop-$1'." >&2 exit 1 ;; - "true restarting $3:"*) - echo "$2 is restarting; you can stop it with 'weave stop-$1'." >&2 - exit 1 - ;; "true "*" $3") echo "$2 is already running." >&2 exit 1 ;; - "true "*" $3:"*) - echo "$2 is already running." >&2 - exit 1 - ;; "false "*" $3") docker rm $2 >/dev/null ;; - "false "*" $3:"*) - docker rm $2 >/dev/null - ;; true*) echo "Found another running container named '$2'. Aborting." >&2 exit 1 From c19edec36460a6c7d65b860819ab37830c934f57 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 22 Dec 2015 13:04:06 +0000 Subject: [PATCH 5/5] Add 'weave stop-xxx' instructions for 'already running' case --- weave | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weave b/weave index 90a78011..b5051125 100755 --- a/weave +++ b/weave @@ -915,7 +915,7 @@ check_not_running() { exit 1 ;; "true "*" $3") - echo "$2 is already running." >&2 + echo "$2 is already running; you can stop it with 'weave stop-$1'." >&2 exit 1 ;; "false "*" $3")