From 3674808244f31005b9929314b9daaaa1c547ef92 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 21 Nov 2016 09:50:30 +0000 Subject: [PATCH] Remove weave bridge and associated devices if something goes wrong when creating it Otherwise it is left in a half-created state and the user has to run `weave reset` to continue. --- weave | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/weave b/weave index a4f787cc..cae010b1 100755 --- a/weave +++ b/weave @@ -571,7 +571,7 @@ detect_bridge_type() { MTU=${WEAVE_MTU:-$(cat /sys/class/net/$BRIDGE/mtu)} } -create_bridge() { +try_create_bridge() { if ! detect_bridge_type ; then BRIDGE_TYPE=bridge if [ -z "$WEAVE_NO_FASTDP" ] ; then @@ -656,6 +656,16 @@ EOF configure_arp_cache $BRIDGE } +create_bridge() { + if ! try_create_bridge "$@" ; then + echo "Creating bridge '$BRIDGE' failed" >&2 + # reset to original value so we destroy both kinds + DATAPATH=datapath + destroy_bridge + exit 1 + fi +} + expose_ip() { ipam_cidrs allocate_no_check_alive weave:expose $CIDR_ARGS for CIDR in $ALL_CIDRS ; do