diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-27 15:08:56 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-27 15:08:56 +0000 |
commit | 524a21e75209d2501b23b648daf753e3a4bebe56 (patch) | |
tree | aeed4e65e44cee9e0b23298da15828655d23dc94 /scripts/utils.sh | |
parent | b59833305bfaf6b0b3347ad2b626c90c3b3fd5fc (diff) | |
download | gitlab-ce-524a21e75209d2501b23b648daf753e3a4bebe56.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts/utils.sh')
-rw-r--r-- | scripts/utils.sh | 22 |
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 } |