From dce73559b76847fb50b05ad2d5a6372ac7579b99 Mon Sep 17 00:00:00 2001 From: Michael Bridgen Date: Mon, 17 Nov 2014 15:58:11 +0000 Subject: [PATCH 1/4] Differentiate between failure cases in http_call .. otherwise, no networking can look like no running container. --- weave | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/weave b/weave index b00eadcc..b1b01072 100755 --- a/weave +++ b/weave @@ -270,19 +270,28 @@ detach() { # Call url $4 on container $2 at port $3 with http verb $1 http_call() { http_verb="$1" - if ! DOCKERIP=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' $2 2>/dev/null) ; then - echo "$2 is not running." >&2 - exit 1 - fi - if [ -z "$DOCKERIP" ] ; then - echo "$2 is not running." >&2 + if ! status=$(docker inspect --format='{{ .State.Running }} {{ .NetworkSettings.IPAddress }}' $2 2>/dev/null); then + echo "$2 is not a container; have you launched it?" >&2 exit 1 fi + case "$status" in + "true ") + echo "$2 has no IP address; is Docker networking running?" >&2 + exit 1 + ;; + true*) + ip=$(echo $status | sed -e 's/true //') + ;; + *) + echo "$2 is not running." >&2 + exit 1 + ;; + esac port="$3" url="$4" shift 4 if command_exists curl ; then - curl -s -X $http_verb "$@" http://$DOCKERIP:$port$url + curl -s -X $http_verb "$@" http://$ip:$port$url else echo "Cannot find curl, which is required for this operation." >&2 exit 1 From 40de90a4c23efacf101e519be4a63e0df4c70d43 Mon Sep 17 00:00:00 2001 From: Michael Bridgen Date: Mon, 17 Nov 2014 16:24:48 +0000 Subject: [PATCH 2/4] Better terminologicals for no-IP case --- weave | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weave b/weave index b1b01072..9b46a060 100755 --- a/weave +++ b/weave @@ -276,7 +276,7 @@ http_call() { fi case "$status" in "true ") - echo "$2 has no IP address; is Docker networking running?" >&2 + echo "$2 has no IP address; is Docker networking enabled?" >&2 exit 1 ;; true*) From 61d2595c76b7c1d24effc00428ef4e1829c9490e Mon Sep 17 00:00:00 2001 From: Michael Bridgen Date: Mon, 17 Nov 2014 16:28:11 +0000 Subject: [PATCH 3/4] Better phrasing for http_call error messages --- weave | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weave b/weave index 9b46a060..3a33d506 100755 --- a/weave +++ b/weave @@ -271,19 +271,19 @@ detach() { http_call() { http_verb="$1" if ! status=$(docker inspect --format='{{ .State.Running }} {{ .NetworkSettings.IPAddress }}' $2 2>/dev/null); then - echo "$2 is not a container; have you launched it?" >&2 + echo "$2 container is not present; have you launched it?" >&2 exit 1 fi case "$status" in "true ") - echo "$2 has no IP address; is Docker networking enabled?" >&2 + echo "$2 container has no IP address; is Docker networking enabled?" >&2 exit 1 ;; true*) ip=$(echo $status | sed -e 's/true //') ;; *) - echo "$2 is not running." >&2 + echo "$2 container is not running." >&2 exit 1 ;; esac From 308ef865c565c29cc9f04132643f434600b67b98 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 17 Nov 2014 17:39:33 +0000 Subject: [PATCH 4/4] simplify --- weave | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weave b/weave index 3a33d506..270e3778 100755 --- a/weave +++ b/weave @@ -280,7 +280,7 @@ http_call() { exit 1 ;; true*) - ip=$(echo $status | sed -e 's/true //') + ip="${status#true }" ;; *) echo "$2 container is not running." >&2