Skip to content
Myr

[actions] retry apt package installs through Ubuntu mirror outages

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Mirror outages have outlasted the existing retries, which covered only `apt-get update` (and not the WSL `additional-packages` install). Installs now go through `.github/scripts/apt-install.sh`, which retries each request within apt and retries the whole update+install with backoff for about 10 minutes.

authored by Jordan Harband · committed by Jordan Harband · parent ed1b96f · Browse files · 7 files+91 added−39 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+91 added−39 removed

  • other:+91 added−39 removed

7 files+91 added−39 removed

added:.github/scripts/apt-install.sh+49 added
modified:.github/workflows/tests-fast.yml+8 added-4 removed
58 unmodified lines
59 git submodule sync --recursive60 git submodule update --init --recursive61 - name: Install zsh, additional shells, and awk variant62 run: |63 sudo apt-get update64 sudo apt-get install -y zsh ${{ matrix.awk }}63 PACKAGES="zsh ${{ matrix.awk }}"64 if [ "${{ matrix.shell }}" != "sh" ] && [ "${{ matrix.shell }}" != "bash" ] && [ "${{ matrix.shell }}" != "zsh" ]; then66 sudo apt-get install -y ${{ matrix.shell }}65 PACKAGES="${PACKAGES} ${{ matrix.shell }}"66 fi67 sh .github/scripts/apt-install.sh ${PACKAGES}68 # Set the selected awk as the default69 sudo update-alternatives --set awk /usr/bin/${{ matrix.awk }}70 shell: bash71 - run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }}
121 unmodified lines
193 - uses: actions/checkout@v6194 - uses: Vampire/setup-wsl@v7195 with:196 distribution: ${{ matrix.wsl-distrib }}197 - name: Install packages with retries198 # the Windows checkout has CRLF line endings199 run: |200 tr -d '\r' < "$(wslpath "${{ github.workspace }}")/.github/scripts/apt-install.sh" > /tmp/apt-install.sh197 additional-packages: git make zsh dash sudo curl wget ca-certificates nodejs npm201 sh /tmp/apt-install.sh git make zsh dash sudo curl wget ca-certificates nodejs npm202 - name: 'Clone into the WSL filesystem as a non-root user'203 # the Windows checkout shows every file as executable, which urchin would run as tests204 run: |205 set -ex
35 unmodified lines
modified:.github/workflows/tests-installation-iojs.yml+4 added-4 removed
modified:.github/workflows/tests-installation-node.yml+2 added-14 removed
81 unmodified lines
82 ubuntu:16.04 \83 bash -c '84 set -ex8586 # Retry apt-get update up to 5 times due to flaky Ubuntu mirrors87 # apt-get update can return 0 even with partial failures, so check for warnings88 for i in 1 2 3 4 5; do89 if apt-get update 2>&1 | tee /tmp/apt-update.log | grep -qE "^(W:|E:|Err:)"; then90 echo "apt-get update had warnings/errors, attempt $i/5"91 cat /tmp/apt-update.log92 sleep $((i * 5))93 else94 break95 fi96 done9798 apt-get install -y git curl wget make build-essential python zsh libssl-dev86 sh /workspace/.github/scripts/apt-install.sh git curl wget make build-essential python zsh libssl-dev87 if [ "$TEST_SHELL" != "sh" ] && [ "$TEST_SHELL" != "bash" ]; then100 apt-get install -y $TEST_SHELL || true88 sh /workspace/.github/scripts/apt-install.sh $TEST_SHELL || true89 fi9091 # Use nvm to install Node.js for running urchin92 # Node 16 is the last version supporting GLIBC 2.23 (Ubuntu 16.04)
34 unmodified lines
modified:.github/workflows/tests-xenial.yml+2 added-14 removed
77 unmodified lines
78 ubuntu:16.04 \79 bash -c '80 set -ex8182 # Retry apt-get update up to 5 times due to flaky Ubuntu mirrors83 # apt-get update can return 0 even with partial failures, so check for warnings84 for i in 1 2 3 4 5; do85 if apt-get update 2>&1 | tee /tmp/apt-update.log | grep -qE "^(W:|E:|Err:)"; then86 echo "apt-get update had warnings/errors, attempt $i/5"87 cat /tmp/apt-update.log88 sleep $((i * 5))89 else90 break91 fi92 done9394 apt-get install -y git curl wget make build-essential python zsh libssl-dev82 sh /workspace/.github/scripts/apt-install.sh git curl wget make build-essential python zsh libssl-dev83 if [ "$TEST_SHELL" != "sh" ] && [ "$TEST_SHELL" != "bash" ]; then96 apt-get install -y $TEST_SHELL || true84 sh /workspace/.github/scripts/apt-install.sh $TEST_SHELL || true85 fi8687 # Use nvm to install Node.js for running urchin88 # Node 16 is the last version supporting GLIBC 2.23 (Ubuntu 16.04)
28 unmodified lines
modified:.github/workflows/tests.yml+1 added-1 removed
52 unmodified lines
53 iojs.org:44354 azure.archive.ubuntu.com:8055 packages.microsoft.com:44356 - uses: actions/checkout@v657 - run: sudo apt-get update; sudo apt-get install ${{ matrix.shell }}57 - run: sh .github/scripts/apt-install.sh ${{ matrix.shell }}58 if: matrix.shell == 'zsh' || matrix.shell == 'ksh'59 # zsh (https://github.com/actions/runner-images/issues/264) and ksh are not in the ubuntu image60 shell: bash61 - run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }}
32 unmodified lines
modified:.github/workflows/windows-nvm.yml+25 added-2 removed
143 unmodified lines
144 method:145 - ''146 - 'script'147 steps:148 # For Ubuntu: install with packages directly148 # For Ubuntu: `additional-packages` can't retry, so install in a separate step149 - if: ${{ !startsWith(matrix.wsl-distrib, 'Debian') }}150 uses: Vampire/setup-wsl@v7151 with:152 distribution: ${{ matrix.wsl-distrib }}153 additional-packages: bash git curl ca-certificates wget153 # mirror outages can outlast apt's own retries, so retry update+install with154 # backoff for about 10 minutes (as .github/scripts/apt-install.sh does; this155 # job has no checkout)156 - if: ${{ !startsWith(matrix.wsl-distrib, 'Debian') }}157 name: 'Install packages with retries'158 shell: 'wsl-bash {0}'159 run: |160 attempt=1161 delay=15162 while true; do163 apt-get -o Acquire::Retries=5 update || true164 if apt-get -o Acquire::Retries=5 install --yes bash git curl ca-certificates wget; then165 break166 fi167 if [ "${attempt}" -ge 8 ]; then168 echo "apt-get install failed after ${attempt} attempts" >&2169 exit 1170 fi171 echo "apt-get install failed (attempt ${attempt}/8); retrying in ${delay}s" >&2172 sleep "${delay}"173 attempt=$((attempt + 1))174 delay=$((delay * 2))175 if [ "${delay}" -gt 120 ]; then delay=120; fi176 done177178 # For Debian, install without packages: `additional-packages` would run179 # `apt-get update` before we get to fix up sources.list180 # see https://github.com/Vampire/setup-wsl/issues/76
124 unmodified lines