Retry apt-get commands when using Ubuntu servers They still fail, even when using versions later than 18.04, but the failure is usually temporary, so try them several times.
| ... | ... | @@ -169,11 +169,30 @@ jobs: |
| 169 | 169 | exit 1
|
| 170 | 170 | esac
|
| 171 | 171 | |
| 172 | + # Ubuntu servers sometimes fail because of transient network
|
|
| 173 | + # issues, so retry apt-get commands a few times before giving up.
|
|
| 174 | + retry_apt()
|
|
| 175 | + {
|
|
| 176 | + attempts=5
|
|
| 177 | + delay=30
|
|
| 178 | + attempt=1
|
|
| 179 | + |
|
| 180 | + while ! "$@"; do
|
|
| 181 | + if [[ $attempt -ge $attempts ]]; then
|
|
| 182 | + return 1
|
|
| 183 | + fi
|
|
| 184 | + |
|
| 185 | + echo "Command failed, retrying in ${delay}s (attempt $((attempt + 1))/$attempts): $*"
|
|
| 186 | + attempt=$((attempt + 1))
|
|
| 187 | + sleep $delay
|
|
| 188 | + done
|
|
| 189 | + }
|
|
| 190 | + retry_apt apt-get update -qq
|
|
| 191 | + |
|
| 172 | 192 | # Explanation for installing some less obvious packages:
|
| 173 | 193 | # - coreutils contains nproc used in proc_count.sh called below.
|
| 174 | 194 | # - xvfb is used for running the GUI tests.
|
| 175 | - apt-get update -qq
|
|
| 176 | - apt-get install -qq coreutils ${compiler_packages} git make pkg-config sudo xvfb
|
|
| 195 | + retry_apt apt-get install -qq coreutils ${compiler_packages} git make pkg-config sudo xvfb
|
|
| 177 | 196 | ;;
|
| 178 | 197 | |
| 179 | 198 | '')
|
—
View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help