Kokoro: Retry gclient sync

Network IO appears to flake. Try up to 5 times before giving up.

Change-Id: I1c58e2b603495835d2410a1256aa70c0fe10ee98
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49340
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-04-28 08:59:03 +00:00 committed by Commit Bot service account
parent 5bdece5583
commit 70c8a96cd8
1 changed files with 16 additions and 1 deletions

View File

@ -38,6 +38,21 @@ function status {
echo "" echo ""
task_begin $@ task_begin $@
} }
function with_retry {
local MAX_ATTEMPTS=5
local RETRY_DELAY_SECS=5
local ATTEMPT=1
while true; do
"$@" && break
if [[ $ATTEMPT -ge $MAX_ATTEMPTS ]]; then
echo "The command has failed after $ATTEMPT attempts."
exit $?
fi
((ATTEMPT++))
echo "'$@' failed. Attempt ($ATTEMPT/$MAX_ATTEMPTS). Retrying..."
sleep $RETRY_DELAY_SECS;
done
}
ORIGINAL_SRC_DIR="$(pwd)" ORIGINAL_SRC_DIR="$(pwd)"
@ -55,7 +70,7 @@ git clone ${ORIGINAL_SRC_DIR} .
status "Fetching dependencies" status "Fetching dependencies"
cp standalone.gclient .gclient cp standalone.gclient .gclient
gclient sync with_retry gclient sync
status "Configuring build system" status "Configuring build system"
if [ "$BUILD_SYSTEM" == "cmake" ]; then if [ "$BUILD_SYSTEM" == "cmake" ]; then