From 9210cc598df1180b33757cd33dd05101c1872f96 Mon Sep 17 00:00:00 2001 From: BtbN Date: Fri, 2 Sep 2022 14:26:23 +0200 Subject: [PATCH] Add incremenal backoff and random delay to retry tool --- images/base/retry-tool.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/images/base/retry-tool.sh b/images/base/retry-tool.sh index 548e2e4..75c8b8d 100755 --- a/images/base/retry-tool.sh +++ b/images/base/retry-tool.sh @@ -2,10 +2,12 @@ set -xe RETRY_COUNTER=0 -MAX_RETRY=15 +MAX_RETRY=10 +CUR_TIMEOUT=120 while [[ $RETRY_COUNTER -lt $MAX_RETRY ]]; do - timeout 120 "$@" && break || sleep 10 + timeout $CUR_TIMEOUT "$@" && break || sleep $(shuf -i 5-90 -n 1) RETRY_COUNTER=$(( $RETRY_COUNTER + 1 )) + CUR_TIMEOUT=$(( $CUR_TIMEOUT + 60 )) echo "Retry $RETRY_COUNTER..." done if [[ $RETRY_COUNTER -ge $MAX_RETRY ]]; then