From 34abe0a325d250588d9ee5db8a260fcee7e08339 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Sat, 5 Oct 2024 18:38:06 +0200 Subject: [PATCH] Retry network removal when cleaning up before and after test runs. --- bin/run-tests-on-swarm.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/run-tests-on-swarm.sh b/bin/run-tests-on-swarm.sh index c9a752501..c4f2d7e39 100755 --- a/bin/run-tests-on-swarm.sh +++ b/bin/run-tests-on-swarm.sh @@ -190,9 +190,16 @@ docker_cleanup() { fi if docker network inspect $NETWORK &> /dev/null; then - if ! docker network rm $NETWORK &> /dev/null; then - log_debug "Could not remove network $NETWORK" - else + retries=5 + while test $retries -gt 0; do + if docker network rm $NETWORK &> /dev/null; then + break + fi + retries=$(($retries - 1)) + log_debug "Could not remove network $NETWORK ($retries retries left)" + sleep 2 + done + if test $retries -gt 0; then while [[ -n $(docker network ls | grep "$NETWORK.*swarm") ]]; do log_debug "Waiting for network $NETWORK to be removed." sleep 2