summaryrefslogtreecommitdiff
path: root/scripts/utils.sh
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-27 15:08:56 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-27 15:08:56 +0000
commit524a21e75209d2501b23b648daf753e3a4bebe56 (patch)
treeaeed4e65e44cee9e0b23298da15828655d23dc94 /scripts/utils.sh
parentb59833305bfaf6b0b3347ad2b626c90c3b3fd5fc (diff)
downloadgitlab-ce-524a21e75209d2501b23b648daf753e3a4bebe56.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts/utils.sh')
-rw-r--r--scripts/utils.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/utils.sh b/scripts/utils.sh
index c71de666ac6..44bbabb4c99 100644
--- a/scripts/utils.sh
+++ b/scripts/utils.sh
@@ -10,6 +10,28 @@ function retry() {
return 0
fi
done
+
+ return 1
+}
+
+# Retry after 2s, 4s, 8s, 16s, 32, 64s, 128s
+function retry_exponential() {
+ if eval "$@"; then
+ return 0
+ fi
+
+ local sleep_time=0
+ # The last try will be after 2**7 = 128 seconds (2min8s)
+ for i in 1 2 3 4 5 6 7; do
+ sleep_time=$((2 ** i))
+
+ echo "Sleep for $sleep_time seconds..."
+ sleep $sleep_time
+ echo "[$(date '+%H:%M:%S')] Attempt #$i..."
+ if eval "$@"; then
+ return 0
+ fi
+ done
return 1
}