From 77031baf982ec5d1d6e3f16252298af2f0325d42 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Fri, 4 Dec 2020 13:04:10 +0100 Subject: ci: Prevent some more CI failures Many times the CI pipeline fails in the early stages because the APT repo for LLVM is being updated. Add a retry mechanism for some more APT commands. --- ci/azure/linux_script | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/ci/azure/linux_script b/ci/azure/linux_script index aba1555a7d..45321b1adc 100755 --- a/ci/azure/linux_script +++ b/ci/azure/linux_script @@ -3,32 +3,38 @@ set -x set -e +# This parameters we wait at most 2mins, it should be enough to sort out any +# transient error. +CMD_MAX_RETRY=12 +CMD_WAIT_TIME=10s + +# Execute the given command and, in case of failure, try to execute it again +# after sleeping for CMD_WAIT_TIME. +# We give up after retrying CMD_MAX_RETRY times. +retry() { + for i in $(seq 1 "$CMD_MAX_RETRY"); do + "$@" && return + echo "command \"$@\" failed, retrying..." + sleep ${CMD_WAIT_TIME} + done + + echo "command \"$@\" failed, giving up..." + exit 1 +} + BUILDDIR="$(pwd)" sudo sh -c 'echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main" >> /etc/apt/sources.list' -wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - -sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test +retry 'wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -' +retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get remove -y llvm-* sudo rm -rf /usr/local/* -# Some APT mirrors can be flaky, retry the download instead of failing right -# away. -APT_MAX_RETRY=3 - -for i in $(seq 1 "$APT_MAX_RETRY"); do - sudo apt-get update -q - sudo apt-get install -y \ +retry sudo apt-get update -q +retry sudo apt-get install -y \ libxml2-dev libclang-11-dev llvm-11 llvm-11-dev liblld-11-dev cmake s3cmd \ gcc-7 g++-7 ninja-build tidy \ - && break - if [ "$i" -eq "$APT_MAX_RETRY" ]; then - echo 'apt-get failed, giving up...' - exit 1 - fi - echo 'apt-get failed, retrying...' - sleep 5s -done QEMUBASE="qemu-linux-x86_64-5.1.0" wget https://ziglang.org/deps/$QEMUBASE.tar.xz -- cgit v1.2.3 From 2282eb1be18fd2c76caec12d21fea55d9820d5b5 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Fri, 4 Dec 2020 13:08:46 +0100 Subject: ci: Use -nv flag for wget -nv, --no-verbose turn off verboseness, without being quiet --- ci/azure/linux_script | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/azure/linux_script b/ci/azure/linux_script index 45321b1adc..2b6d62d253 100755 --- a/ci/azure/linux_script +++ b/ci/azure/linux_script @@ -37,12 +37,12 @@ retry sudo apt-get install -y \ gcc-7 g++-7 ninja-build tidy \ QEMUBASE="qemu-linux-x86_64-5.1.0" -wget https://ziglang.org/deps/$QEMUBASE.tar.xz +wget -nv https://ziglang.org/deps/$QEMUBASE.tar.xz tar xf $QEMUBASE.tar.xz PATH=$PWD/$QEMUBASE/bin:$PATH WASMTIME="wasmtime-v0.20.0-x86_64-linux" -wget https://github.com/bytecodealliance/wasmtime/releases/download/v0.20.0/$WASMTIME.tar.xz +wget -nv https://github.com/bytecodealliance/wasmtime/releases/download/v0.20.0/$WASMTIME.tar.xz tar xf $WASMTIME.tar.xz PATH=$PWD/$WASMTIME:$PATH -- cgit v1.2.3 From 55838bc2910f3f73762ea513536b74af056ed9ec Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Fri, 4 Dec 2020 17:31:27 +0100 Subject: ci: Use eval to make retry() work for pipelines too --- ci/azure/linux_script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/azure/linux_script b/ci/azure/linux_script index 2b6d62d253..06e44aa52a 100755 --- a/ci/azure/linux_script +++ b/ci/azure/linux_script @@ -13,7 +13,7 @@ CMD_WAIT_TIME=10s # We give up after retrying CMD_MAX_RETRY times. retry() { for i in $(seq 1 "$CMD_MAX_RETRY"); do - "$@" && return + eval "$@" && return echo "command \"$@\" failed, retrying..." sleep ${CMD_WAIT_TIME} done -- cgit v1.2.3