From 32d39090235e68e8011d77ce13c94a8a69b75951 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 16 Jun 2015 14:47:47 +0100 Subject: [PATCH] Make ipam_cidrs() return failure when call_weave fails --- weave | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/weave b/weave index c5e9eb3b..e653a1bf 100755 --- a/weave +++ b/weave @@ -788,7 +788,9 @@ ipam_cidrs() { IPAM_CIDRs="" if [ $# -eq 0 ] ; then # If no addresses passed in, get one in the default subnet - IPAM_CIDRS=$(call_weave POST /ip/$CONTAINER_ID) + if ! IPAM_CIDRS=$(call_weave POST /ip/$CONTAINER_ID) ; then + return 1 + fi if [ "$IPAM_CIDRS" = "404 page not found" ] ; then echo "No IP address supplied (use the -iprange option on 'weave launch' to enable IP address allocation)" >&2 return 1 @@ -798,9 +800,12 @@ ipam_cidrs() { while [ $# -gt 0 ] ; do if [ "${1%:*}" = "net" ] ; then if [ "$1" = "net:default" ] ; then - CIDR=$(call_weave POST /ip/$CONTAINER_ID) + IPAM_URL=/ip/$CONTAINER_ID else - CIDR=$(call_weave POST /ip/$CONTAINER_ID/"${1#net:}") + IPAM_URL=/ip/$CONTAINER_ID/"${1#net:}" + fi + if ! CIDR=$(call_weave POST $IPAM_URL) ; then + return 1 fi if [ "$CIDR" = "404 page not found" ] ; then echo "IP address allocation must be enabled to use --subnet (use the -iprange option on 'weave launch')" >&2