From e53a8336d087e8d92cf2dc1e0cffc51591df7945 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Oct 2026 15:55:52 +0000 Subject: [PATCH 1/9] Add a temporary workflow to diagnose apt hangs Co-Authored-By: Claude Opus 5.5 --- .github/workflows/apt-diagnostics.yml | 105 ++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 .github/workflows/apt-diagnostics.yml diff --git a/.github/workflows/apt-diagnostics.yml b/.github/workflows/apt-diagnostics.yml new file mode 100644 index 0000000000..4f58599831 --- /dev/null +++ b/.github/workflows/apt-diagnostics.yml @@ -0,0 +1,105 @@ +# Temporary: samples `playwright install-deps` across runners to find why it hangs in CI. +# Removed before merging. +name: apt diagnostics + +on: + pull_request: + +permissions: {} + +defaults: + run: + shell: bash + +jobs: + apt: + name: apt (${{ matrix.mirrors }} ${{ matrix.sample }}) + runs-on: ubuntu-latest + timeout-minutes: 20 + + permissions: {} + + strategy: + fail-fast: false + matrix: + mirrors: [default, archive-first] + sample: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + + steps: + - name: Show runner, DNS, and apt configuration + run: | + echo "::group::runner" + curl -sS --max-time 2 -H Metadata:true --noproxy '*' 'http://169.254.169.254/metadata/instance/compute/location?api-version=2021-02-01&format=text' || true + echo + echo "::endgroup::" + echo "::group::DNS" + for host in azure.archive.ubuntu.com archive.ubuntu.com security.ubuntu.com; do + dig +noall +answer "$host" + done + echo "::endgroup::" + echo "::group::apt" + cat /etc/apt/apt-mirrors.txt + cat /etc/apt/sources.list.d/*.sources + ls -la /etc/apt/apt.conf.d/ /etc/apt/sources.list.d/ + grep -r . /etc/apt/apt.conf.d/ + echo "::endgroup::" + + - name: Prefer archive.ubuntu.com + if: matrix.mirrors == 'archive-first' + run: | + printf '%s\tpriority:%s\n' \ + https://archive.ubuntu.com/ubuntu/ 1 \ + https://security.ubuntu.com/ubuntu/ 2 \ + http://azure.archive.ubuntu.com/ubuntu/ 3 \ + | sudo tee /etc/apt/apt-mirrors.txt + + # same as .github/apt.conf, but with progress output + - name: Configure apt like CI + run: | + printf '%s\n' \ + 'Acquire::Retries "0";' \ + 'Acquire::http::Timeout "10";' \ + 'Acquire::https::Timeout "10";' \ + | sudo tee /etc/apt/apt.conf.d/99-ci + apt-config dump Acquire::Retries Acquire::http::Timeout Acquire::https::Timeout quiet + + - name: Start TCP monitor + run: | + sudo setsid bash -c ' + while :; do + echo "@ $(date -u +%T.%N | cut -c1-12)" + ss -tinpH state established "( dport = :80 or dport = :443 )" + sleep 1 + done' > /tmp/ss.log 2>&1 < /dev/null & + + - name: playwright install-deps + timeout-minutes: 15 + run: | + start=$(date +%s) + npx --yes playwright@1.64.1 install-deps 2>&1 | tee /tmp/install.log + echo "RESULT mirrors=${MIRRORS} seconds=$(($(date +%s) - start))" + env: + MIRRORS: ${{ matrix.mirrors }} + + - name: Summarize apt transfers + if: always() + run: | + grep -E '^(Fetched|Need to get|Err|Ign|W:|E:)' /tmp/install.log || true + # which mirror served the files + grep -oE '^(Get|Hit):[0-9]+ [a-z]+://[^/ ]+' /tmp/install.log | cut -d' ' -f2 | sort | uniq -c || true + + - name: Probe mirror throughput with fresh connections + if: always() + run: | + for mirror in http://azure.archive.ubuntu.com https://archive.ubuntu.com; do + for i in 1 2 3; do + curl -sS -o /dev/null --max-time 30 \ + -w "PROBE $mirror %{remote_ip} %{http_code} %{size_download}B %{time_total}s %{speed_download}B/s\n" \ + "$mirror/ubuntu/dists/noble/universe/binary-amd64/Packages.xz" || true + done + done + + # each second, the connections of apt's http and https methods, and their TCP info + - name: TCP connections of apt's download methods + if: always() + run: awk '/^@/ { t = $2; next } /"https?",/ { print t, $0; getline; print t, $0 }' /tmp/ss.log From cbefbf3a4cc2215ebc97075e83c89996e87d81f5 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Oct 2026 16:03:06 +0000 Subject: [PATCH 2/9] Compare mirror orders and probe the regional mirror's cache Co-Authored-By: Claude Opus 5.5 --- .github/workflows/apt-diagnostics.yml | 81 +++++++++++++++------------ 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/.github/workflows/apt-diagnostics.yml b/.github/workflows/apt-diagnostics.yml index 4f58599831..44394f925d 100644 --- a/.github/workflows/apt-diagnostics.yml +++ b/.github/workflows/apt-diagnostics.yml @@ -13,55 +13,75 @@ defaults: jobs: apt: - name: apt (${{ matrix.mirrors }} ${{ matrix.sample }}) + name: apt (${{ matrix.variant }} ${{ matrix.sample }}) runs-on: ubuntu-latest - timeout-minutes: 20 + timeout-minutes: 15 permissions: {} strategy: fail-fast: false matrix: - mirrors: [default, archive-first] - sample: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + variant: [default, archive, archive-pipelined, archive-security, archive-security-pipelined] + sample: [1, 2, 3, 4, 5] steps: - - name: Show runner, DNS, and apt configuration + - name: Show DNS and apt configuration run: | - echo "::group::runner" - curl -sS --max-time 2 -H Metadata:true --noproxy '*' 'http://169.254.169.254/metadata/instance/compute/location?api-version=2021-02-01&format=text' || true - echo - echo "::endgroup::" echo "::group::DNS" for host in azure.archive.ubuntu.com archive.ubuntu.com security.ubuntu.com; do dig +noall +answer "$host" done echo "::endgroup::" echo "::group::apt" + ls -la /etc/apt/ cat /etc/apt/apt-mirrors.txt - cat /etc/apt/sources.list.d/*.sources - ls -la /etc/apt/apt.conf.d/ /etc/apt/sources.list.d/ - grep -r . /etc/apt/apt.conf.d/ echo "::endgroup::" - - name: Prefer archive.ubuntu.com - if: matrix.mirrors == 'archive-first' + # the regional mirror's cache: the same file, served from the cache, then fetched through it + - name: Probe mirrors run: | - printf '%s\tpriority:%s\n' \ - https://archive.ubuntu.com/ubuntu/ 1 \ - https://security.ubuntu.com/ubuntu/ 2 \ - http://azure.archive.ubuntu.com/ubuntu/ 3 \ - | sudo tee /etc/apt/apt-mirrors.txt + probe() { + curl -sS -o /dev/null -D /tmp/headers --max-time 20 \ + -w "PROBE $1 %{remote_ip} %{http_code} %{size_download}B %{time_total}s %{speed_download}B/s" "$2" || true + echo " $(grep -i -E '^(via|x-cache):' /tmp/headers | tr -d '\r' | tr '\n' ' ')" + } + file=ubuntu/dists/noble/universe/binary-amd64/Packages.xz + for i in 1 2; do + probe azure-cached "http://azure.archive.ubuntu.com/$file" + probe azure-uncached "http://azure.archive.ubuntu.com/$file?$RANDOM$RANDOM" + probe archive "https://archive.ubuntu.com/$file" + done + probe azure-pool "http://azure.archive.ubuntu.com/ubuntu/pool/main/g/gtk4/libgtk-4-1_4.14.5+ds-0ubuntu0.10_amd64.deb" - # same as .github/apt.conf, but with progress output - - name: Configure apt like CI + - name: Configure apt run: | + # as .github/apt.conf, without `quiet` printf '%s\n' \ 'Acquire::Retries "0";' \ 'Acquire::http::Timeout "10";' \ 'Acquire::https::Timeout "10";' \ | sudo tee /etc/apt/apt.conf.d/99-ci - apt-config dump Acquire::Retries Acquire::http::Timeout Acquire::https::Timeout quiet + case "$VARIANT" in + archive*) + security_priority=2 + if [[ $VARIANT == archive-security* ]]; then + security_priority=1 + fi + printf '%s\tpriority:%s\n' \ + https://archive.ubuntu.com/ubuntu/ 1 \ + https://security.ubuntu.com/ubuntu/ "$security_priority" \ + http://azure.archive.ubuntu.com/ubuntu/ 3 \ + | sudo tee /etc/apt/apt-mirrors.txt + ;; + esac + if [[ $VARIANT == *-pipelined ]]; then + # read after /etc/apt/apt.conf.d/, so it overrides 99bad_proxy's Pipeline-Depth 0 + echo 'Acquire::https::Pipeline-Depth "10";' | sudo tee /etc/apt/apt.conf + fi + apt-config dump Acquire::Retries Acquire::http Acquire::https quiet + env: + VARIANT: ${{ matrix.variant }} - name: Start TCP monitor run: | @@ -73,13 +93,13 @@ jobs: done' > /tmp/ss.log 2>&1 < /dev/null & - name: playwright install-deps - timeout-minutes: 15 + timeout-minutes: 8 run: | start=$(date +%s) npx --yes playwright@1.64.1 install-deps 2>&1 | tee /tmp/install.log - echo "RESULT mirrors=${MIRRORS} seconds=$(($(date +%s) - start))" + echo "RESULT variant=${VARIANT} seconds=$(($(date +%s) - start))" env: - MIRRORS: ${{ matrix.mirrors }} + VARIANT: ${{ matrix.variant }} - name: Summarize apt transfers if: always() @@ -88,17 +108,6 @@ jobs: # which mirror served the files grep -oE '^(Get|Hit):[0-9]+ [a-z]+://[^/ ]+' /tmp/install.log | cut -d' ' -f2 | sort | uniq -c || true - - name: Probe mirror throughput with fresh connections - if: always() - run: | - for mirror in http://azure.archive.ubuntu.com https://archive.ubuntu.com; do - for i in 1 2 3; do - curl -sS -o /dev/null --max-time 30 \ - -w "PROBE $mirror %{remote_ip} %{http_code} %{size_download}B %{time_total}s %{speed_download}B/s\n" \ - "$mirror/ubuntu/dists/noble/universe/binary-amd64/Packages.xz" || true - done - done - # each second, the connections of apt's http and https methods, and their TCP info - name: TCP connections of apt's download methods if: always() From 4b22ca0e5449326e2b879d2434fc3a070e7e9e81 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Oct 2026 16:20:44 +0000 Subject: [PATCH 3/9] Download the browsers' apt dependencies from archive.ubuntu.com, with a time limit Co-Authored-By: Claude Opus 5.5 --- .github/apt-mirrors.txt | 7 ++ .github/apt.conf | 12 +-- .github/install-browsers.sh | 28 ++++++ .github/workflows/apt-diagnostics.yml | 118 +++++++++----------------- vite.config.ts | 9 +- 5 files changed, 84 insertions(+), 90 deletions(-) create mode 100644 .github/apt-mirrors.txt create mode 100644 .github/install-browsers.sh diff --git a/.github/apt-mirrors.txt b/.github/apt-mirrors.txt new file mode 100644 index 0000000000..77171f04e7 --- /dev/null +++ b/.github/apt-mirrors.txt @@ -0,0 +1,7 @@ +# Replaces the runner image's /etc/apt/apt-mirrors.txt, which lists azure.archive.ubuntu.com first. +# It resolves to a mirror in the runner's Azure region, and the westus and westus3 mirrors relay packages +# from upstream at ~50 kB/s, which apt can take ~40 minutes to download, as it never fails over from a slow mirror: +# https://github.com/actions/runner-images/issues/14823 +https://archive.ubuntu.com/ubuntu/ priority:1 +https://security.ubuntu.com/ubuntu/ priority:2 +http://azure.archive.ubuntu.com/ubuntu/ priority:3 diff --git a/.github/apt.conf b/.github/apt.conf index 2150f97d4d..5ab133f795 100644 --- a/.github/apt.conf +++ b/.github/apt.conf @@ -1,5 +1,7 @@ -// fail fast instead of hanging on unresponsive mirrors -Acquire::Retries "0"; -Acquire::http::Timeout "10"; -Acquire::https::Timeout "10"; -quiet "2"; +// Installed as /etc/apt/apt.conf, which apt reads after /etc/apt/apt.conf.d/, +// so it overrides the runner image's settings. + +// The runner image turns off pipelining, so each package costs a round trip, +// and downloading them from archive.ubuntu.com takes 5 times longer. +// No proxy can break pipelining over HTTPS. +Acquire::https::Pipeline-Depth "10"; diff --git a/.github/install-browsers.sh b/.github/install-browsers.sh new file mode 100644 index 0000000000..be8284e7a8 --- /dev/null +++ b/.github/install-browsers.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# The `install-browsers` task on CI: installs the browsers, and their system dependencies with apt +set -euo pipefail + +echo '::group::Install browsers' + +# see the comments in these files +sudo cp .github/apt.conf /etc/apt/apt.conf +image_mirrors=$(mktemp) +cp /etc/apt/apt-mirrors.txt "$image_mirrors" +sudo cp .github/apt-mirrors.txt /etc/apt/apt-mirrors.txt + +# apt only fails over to the next mirror after an error, so any mirror that keeps sending data, however slowly, stalls it. +# The downloads normally take about 10 seconds, so after a minute, they're retried with the runner image's mirrors, +# keeping the packages already downloaded. +# Playwright's `apt-get install` only downloads the packages here, so stopping it can't interrupt dpkg. +echo 'APT::Get::Download-Only "true";' | sudo tee /etc/apt/apt.conf.d/download-only > /dev/null +if ! timeout 60 playwright install-deps; then + echo "::warning::Downloading the browsers' dependencies failed or took over a minute, retrying with the runner image's apt mirrors" + sudo cp "$image_mirrors" /etc/apt/apt-mirrors.txt + timeout 60 playwright install-deps +fi +sudo rm /etc/apt/apt.conf.d/download-only + +# installs the downloaded packages +playwright install --no-shell --with-deps + +echo '::endgroup::' diff --git a/.github/workflows/apt-diagnostics.yml b/.github/workflows/apt-diagnostics.yml index 44394f925d..eec48568e2 100644 --- a/.github/workflows/apt-diagnostics.yml +++ b/.github/workflows/apt-diagnostics.yml @@ -1,4 +1,4 @@ -# Temporary: samples `playwright install-deps` across runners to find why it hangs in CI. +# Temporary: checks that `vp run install-browsers` succeeds quickly across runners. # Removed before merging. name: apt diagnostics @@ -12,103 +12,67 @@ defaults: shell: bash jobs: - apt: - name: apt (${{ matrix.variant }} ${{ matrix.sample }}) + install-browsers: + name: install-browsers (${{ matrix.scenario }} ${{ matrix.sample }}) runs-on: ubuntu-latest timeout-minutes: 15 - permissions: {} + permissions: + contents: read # check out the repository strategy: fail-fast: false matrix: - variant: [default, archive, archive-pipelined, archive-security, archive-security-pipelined] - sample: [1, 2, 3, 4, 5] + scenario: [ci] + sample: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] + include: + # the first attempt downloads from the degraded westus mirror, + # the retry from archive.ubuntu.com + - scenario: slow-mirror + sample: 1 + - scenario: slow-mirror + sample: 2 + - scenario: slow-mirror + sample: 3 steps: - - name: Show DNS and apt configuration - run: | - echo "::group::DNS" - for host in azure.archive.ubuntu.com archive.ubuntu.com security.ubuntu.com; do - dig +noall +answer "$host" - done - echo "::endgroup::" - echo "::group::apt" - ls -la /etc/apt/ - cat /etc/apt/apt-mirrors.txt - echo "::endgroup::" + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - # the regional mirror's cache: the same file, served from the cache, then fetched through it - - name: Probe mirrors - run: | - probe() { - curl -sS -o /dev/null -D /tmp/headers --max-time 20 \ - -w "PROBE $1 %{remote_ip} %{http_code} %{size_download}B %{time_total}s %{speed_download}B/s" "$2" || true - echo " $(grep -i -E '^(via|x-cache):' /tmp/headers | tr -d '\r' | tr '\n' ' ')" - } - file=ubuntu/dists/noble/universe/binary-amd64/Packages.xz - for i in 1 2; do - probe azure-cached "http://azure.archive.ubuntu.com/$file" - probe azure-uncached "http://azure.archive.ubuntu.com/$file?$RANDOM$RANDOM" - probe archive "https://archive.ubuntu.com/$file" - done - probe azure-pool "http://azure.archive.ubuntu.com/ubuntu/pool/main/g/gtk4/libgtk-4-1_4.14.5+ds-0ubuntu0.10_amd64.deb" + - uses: voidzero-dev/setup-vp@68f39c78aaf39be468cabd2afb09c162574c84af # v1.21.2 + with: + run-install: false - - name: Configure apt - run: | - # as .github/apt.conf, without `quiet` - printf '%s\n' \ - 'Acquire::Retries "0";' \ - 'Acquire::http::Timeout "10";' \ - 'Acquire::https::Timeout "10";' \ - | sudo tee /etc/apt/apt.conf.d/99-ci - case "$VARIANT" in - archive*) - security_priority=2 - if [[ $VARIANT == archive-security* ]]; then - security_priority=1 - fi - printf '%s\tpriority:%s\n' \ - https://archive.ubuntu.com/ubuntu/ 1 \ - https://security.ubuntu.com/ubuntu/ "$security_priority" \ - http://azure.archive.ubuntu.com/ubuntu/ 3 \ - | sudo tee /etc/apt/apt-mirrors.txt - ;; - esac - if [[ $VARIANT == *-pipelined ]]; then - # read after /etc/apt/apt.conf.d/, so it overrides 99bad_proxy's Pipeline-Depth 0 - echo 'Acquire::https::Pipeline-Depth "10";' | sudo tee /etc/apt/apt.conf - fi - apt-config dump Acquire::Retries Acquire::http Acquire::https quiet - env: - VARIANT: ${{ matrix.variant }} + - run: vp install --frozen-lockfile - - name: Start TCP monitor + - run: shellcheck .github/install-browsers.sh + if: matrix.scenario == 'slow-mirror' && matrix.sample == 1 + continue-on-error: true + + - name: Simulate a slow first-choice mirror + if: matrix.scenario == 'slow-mirror' run: | - sudo setsid bash -c ' - while :; do - echo "@ $(date -u +%T.%N | cut -c1-12)" - ss -tinpH state established "( dport = :80 or dport = :443 )" - sleep 1 - done' > /tmp/ss.log 2>&1 < /dev/null & + echo '40.81.13.82 azure.archive.ubuntu.com' | sudo tee -a /etc/hosts + printf '%s\tpriority:1\n' http://azure.archive.ubuntu.com/ubuntu/ > .github/apt-mirrors.txt + # the list the script falls back to + printf '%s\tpriority:%s\n' https://archive.ubuntu.com/ubuntu/ 1 https://security.ubuntu.com/ubuntu/ 2 \ + | sudo tee /etc/apt/apt-mirrors.txt - - name: playwright install-deps + - name: vp run install-browsers timeout-minutes: 8 run: | start=$(date +%s) - npx --yes playwright@1.64.1 install-deps 2>&1 | tee /tmp/install.log - echo "RESULT variant=${VARIANT} seconds=$(($(date +%s) - start))" + vp run install-browsers 2>&1 | tee /tmp/install.log + echo "RESULT scenario=${SCENARIO} seconds=$(($(date +%s) - start))" env: - VARIANT: ${{ matrix.variant }} + CI: true + SCENARIO: ${{ matrix.scenario }} - name: Summarize apt transfers if: always() run: | - grep -E '^(Fetched|Need to get|Err|Ign|W:|E:)' /tmp/install.log || true + grep -E '^(Fetched|Need to get|Download complete|Err|Ign|W:|E:|::warning::)' /tmp/install.log || true # which mirror served the files grep -oE '^(Get|Hit):[0-9]+ [a-z]+://[^/ ]+' /tmp/install.log | cut -d' ' -f2 | sort | uniq -c || true - - # each second, the connections of apt's http and https methods, and their TCP info - - name: TCP connections of apt's download methods - if: always() - run: awk '/^@/ { t = $2; next } /"https?",/ { print t, $0; getline; print t, $0 }' /tmp/ss.log + dig +noall +answer azure.archive.ubuntu.com diff --git a/vite.config.ts b/vite.config.ts index e3ecab488f..2bfd826706 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -111,14 +111,7 @@ export default defineConfig({ cache: false }, 'install-browsers': { - command: isCI - ? [ - 'echo ::group::Install browsers', - 'sudo cp .github/apt.conf /etc/apt/apt.conf.d/99-ci', - 'playwright install --no-shell --with-deps', - 'echo ::endgroup::' - ] - : 'playwright install --no-shell', + command: isCI ? 'bash .github/install-browsers.sh' : 'playwright install --no-shell', // browsers are installed outside the workspace, so they cannot be restored from the cache cache: false }, From 9a6aec13bbdc5706f76665afca03e9d7c7ad0f3d Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Oct 2026 16:33:56 +0000 Subject: [PATCH 4/9] Alternate between the runner image's mirrors and archive.ubuntu.com, and stop the apt-get that the time limit leaves running Co-Authored-By: Claude Opus 5.5 --- .github/apt-mirrors.txt | 7 +++--- .github/install-browsers.sh | 35 +++++++++++++++++---------- .github/workflows/apt-diagnostics.yml | 14 ++++------- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/.github/apt-mirrors.txt b/.github/apt-mirrors.txt index 77171f04e7..9cc3378191 100644 --- a/.github/apt-mirrors.txt +++ b/.github/apt-mirrors.txt @@ -1,7 +1,6 @@ -# Replaces the runner image's /etc/apt/apt-mirrors.txt, which lists azure.archive.ubuntu.com first. -# It resolves to a mirror in the runner's Azure region, and the westus and westus3 mirrors relay packages -# from upstream at ~50 kB/s, which apt can take ~40 minutes to download, as it never fails over from a slow mirror: +# The mirrors that install-browsers.sh switches to when the runner image's are slow. +# The image's start with azure.archive.ubuntu.com, which resolves to a mirror in the runner's Azure region, +# and the westus and westus3 mirrors relay packages from upstream at ~50 kB/s: # https://github.com/actions/runner-images/issues/14823 https://archive.ubuntu.com/ubuntu/ priority:1 https://security.ubuntu.com/ubuntu/ priority:2 -http://azure.archive.ubuntu.com/ubuntu/ priority:3 diff --git a/.github/install-browsers.sh b/.github/install-browsers.sh index be8284e7a8..7ee63bbc0a 100644 --- a/.github/install-browsers.sh +++ b/.github/install-browsers.sh @@ -4,22 +4,31 @@ set -euo pipefail echo '::group::Install browsers' -# see the comments in these files +# see the comment in this file sudo cp .github/apt.conf /etc/apt/apt.conf -image_mirrors=$(mktemp) -cp /etc/apt/apt-mirrors.txt "$image_mirrors" -sudo cp .github/apt-mirrors.txt /etc/apt/apt-mirrors.txt -# apt only fails over to the next mirror after an error, so any mirror that keeps sending data, however slowly, stalls it. -# The downloads normally take about 10 seconds, so after a minute, they're retried with the runner image's mirrors, -# keeping the packages already downloaded. -# Playwright's `apt-get install` only downloads the packages here, so stopping it can't interrupt dpkg. +# apt only moves on to the next mirror in /etc/apt/apt-mirrors.txt after an error, +# so any mirror that keeps sending data, however slowly, stalls it: +# https://github.com/actions/runner-images/issues/14823 +# The downloads normally take about 10 seconds, so after 30 seconds, they switch between +# the runner image's mirrors, which start with the runner region's Azure mirror, and archive.ubuntu.com. +# Playwright's `apt-get install` only downloads the packages here, so stopping it can't interrupt dpkg, +# and each attempt keeps the packages that the previous ones downloaded. +mirror_lists=("$(mktemp)" .github/apt-mirrors.txt) +cp /etc/apt/apt-mirrors.txt "${mirror_lists[0]}" echo 'APT::Get::Download-Only "true";' | sudo tee /etc/apt/apt.conf.d/download-only > /dev/null -if ! timeout 60 playwright install-deps; then - echo "::warning::Downloading the browsers' dependencies failed or took over a minute, retrying with the runner image's apt mirrors" - sudo cp "$image_mirrors" /etc/apt/apt-mirrors.txt - timeout 60 playwright install-deps -fi +for attempt in 0 1 2 3; do + sudo cp "${mirror_lists[attempt % 2]}" /etc/apt/apt-mirrors.txt + if timeout 30 playwright install-deps; then + break + elif [ "$attempt" = 3 ]; then + exit 1 + fi + echo "::warning::Downloading the browsers' dependencies failed or took over 30 seconds, switching apt mirrors" + # the time limit stops Playwright, and sudo only relays it to the shell running apt-get + sudo pkill -KILL -x apt-get || true + while pgrep -x apt-get > /dev/null; do sleep 1; done +done sudo rm /etc/apt/apt.conf.d/download-only # installs the downloaded packages diff --git a/.github/workflows/apt-diagnostics.yml b/.github/workflows/apt-diagnostics.yml index eec48568e2..7f04b7d166 100644 --- a/.github/workflows/apt-diagnostics.yml +++ b/.github/workflows/apt-diagnostics.yml @@ -26,8 +26,6 @@ jobs: scenario: [ci] sample: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] include: - # the first attempt downloads from the degraded westus mirror, - # the retry from archive.ubuntu.com - scenario: slow-mirror sample: 1 - scenario: slow-mirror @@ -50,14 +48,10 @@ jobs: if: matrix.scenario == 'slow-mirror' && matrix.sample == 1 continue-on-error: true + # the first attempt downloads from the degraded westus mirror - name: Simulate a slow first-choice mirror if: matrix.scenario == 'slow-mirror' - run: | - echo '40.81.13.82 azure.archive.ubuntu.com' | sudo tee -a /etc/hosts - printf '%s\tpriority:1\n' http://azure.archive.ubuntu.com/ubuntu/ > .github/apt-mirrors.txt - # the list the script falls back to - printf '%s\tpriority:%s\n' https://archive.ubuntu.com/ubuntu/ 1 https://security.ubuntu.com/ubuntu/ 2 \ - | sudo tee /etc/apt/apt-mirrors.txt + run: echo '40.81.13.82 azure.archive.ubuntu.com' | sudo tee -a /etc/hosts - name: vp run install-browsers timeout-minutes: 8 @@ -72,7 +66,9 @@ jobs: - name: Summarize apt transfers if: always() run: | - grep -E '^(Fetched|Need to get|Download complete|Err|Ign|W:|E:|::warning::)' /tmp/install.log || true + grep -E '^(Fetched|Need to get|Download complete|Err|Ign|W:|E:)' /tmp/install.log || true + echo "SWITCHES $(grep -c '^::warning::' /tmp/install.log || true)" # which mirror served the files grep -oE '^(Get|Hit):[0-9]+ [a-z]+://[^/ ]+' /tmp/install.log | cut -d' ' -f2 | sort | uniq -c || true dig +noall +answer azure.archive.ubuntu.com + echo "LEFTOVER $(pgrep -c -x apt-get || true) apt-get processes" From 77691458ca12ec3a6cf736a48747a11726808bd1 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Oct 2026 16:41:13 +0000 Subject: [PATCH 5/9] Start with archive.ubuntu.com, and only switch mirrors after an attempt that barely downloads anything Co-Authored-By: Claude Opus 5.5 --- .github/apt-mirrors.txt | 4 +-- .github/install-browsers.sh | 31 ++++++++++++--------- .github/workflows/apt-diagnostics.yml | 39 ++++++++++++++++++--------- 3 files changed, 48 insertions(+), 26 deletions(-) diff --git a/.github/apt-mirrors.txt b/.github/apt-mirrors.txt index 9cc3378191..c459756a22 100644 --- a/.github/apt-mirrors.txt +++ b/.github/apt-mirrors.txt @@ -1,5 +1,5 @@ -# The mirrors that install-browsers.sh switches to when the runner image's are slow. -# The image's start with azure.archive.ubuntu.com, which resolves to a mirror in the runner's Azure region, +# The mirrors that install-browsers.sh starts with, before the runner image's. +# Those start with azure.archive.ubuntu.com, which resolves to a mirror in the runner's Azure region, # and the westus and westus3 mirrors relay packages from upstream at ~50 kB/s: # https://github.com/actions/runner-images/issues/14823 https://archive.ubuntu.com/ubuntu/ priority:1 diff --git a/.github/install-browsers.sh b/.github/install-browsers.sh index 7ee63bbc0a..81c52d8da7 100644 --- a/.github/install-browsers.sh +++ b/.github/install-browsers.sh @@ -4,30 +4,37 @@ set -euo pipefail echo '::group::Install browsers' -# see the comment in this file +# see the comments in these files sudo cp .github/apt.conf /etc/apt/apt.conf +mirror_lists=(.github/apt-mirrors.txt "$(mktemp)") +cp /etc/apt/apt-mirrors.txt "${mirror_lists[1]}" # apt only moves on to the next mirror in /etc/apt/apt-mirrors.txt after an error, # so any mirror that keeps sending data, however slowly, stalls it: # https://github.com/actions/runner-images/issues/14823 -# The downloads normally take about 10 seconds, so after 30 seconds, they switch between -# the runner image's mirrors, which start with the runner region's Azure mirror, and archive.ubuntu.com. -# Playwright's `apt-get install` only downloads the packages here, so stopping it can't interrupt dpkg, -# and each attempt keeps the packages that the previous ones downloaded. -mirror_lists=("$(mktemp)" .github/apt-mirrors.txt) -cp /etc/apt/apt-mirrors.txt "${mirror_lists[0]}" +# Instead, Playwright's `apt-get install` only downloads the packages here, in attempts of 30 seconds, +# as they normally take about 10. After an attempt that downloads less than 10 MB, the next one switches +# between .github/apt-mirrors.txt and the runner image's mirrors, and the third such attempt fails. +# Each attempt keeps the packages that the previous ones downloaded, and stopping one can't interrupt dpkg. echo 'APT::Get::Download-Only "true";' | sudo tee /etc/apt/apt.conf.d/download-only > /dev/null -for attempt in 0 1 2 3; do - sudo cp "${mirror_lists[attempt % 2]}" /etc/apt/apt-mirrors.txt +list=0 +stalls=0 +while true; do + sudo cp "${mirror_lists[list]}" /etc/apt/apt-mirrors.txt + downloaded=$(sudo du -sm /var/cache/apt/archives | cut -f1) if timeout 30 playwright install-deps; then break - elif [ "$attempt" = 3 ]; then - exit 1 fi - echo "::warning::Downloading the browsers' dependencies failed or took over 30 seconds, switching apt mirrors" + echo "::warning::Downloading the browsers' dependencies failed or took over 30 seconds" # the time limit stops Playwright, and sudo only relays it to the shell running apt-get sudo pkill -KILL -x apt-get || true while pgrep -x apt-get > /dev/null; do sleep 1; done + if (($(sudo du -sm /var/cache/apt/archives | cut -f1) - downloaded < 10)); then + if ((++stalls == 3)); then + exit 1 + fi + list=$((1 - list)) + fi done sudo rm /etc/apt/apt.conf.d/download-only diff --git a/.github/workflows/apt-diagnostics.yml b/.github/workflows/apt-diagnostics.yml index 7f04b7d166..805c4a3c10 100644 --- a/.github/workflows/apt-diagnostics.yml +++ b/.github/workflows/apt-diagnostics.yml @@ -24,14 +24,14 @@ jobs: fail-fast: false matrix: scenario: [ci] - sample: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] + sample: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] include: - - scenario: slow-mirror - sample: 1 - - scenario: slow-mirror - sample: 2 - - scenario: slow-mirror - sample: 3 + - { scenario: stalled-first, sample: 1 } + - { scenario: stalled-first, sample: 2 } + - { scenario: stalled-first, sample: 3 } + - { scenario: slow-archive, sample: 1 } + - { scenario: slow-archive, sample: 2 } + - { scenario: slow-archive, sample: 3 } steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -45,13 +45,28 @@ jobs: - run: vp install --frozen-lockfile - run: shellcheck .github/install-browsers.sh - if: matrix.scenario == 'slow-mirror' && matrix.sample == 1 + if: matrix.scenario == 'ci' && matrix.sample == 1 continue-on-error: true - # the first attempt downloads from the degraded westus mirror - - name: Simulate a slow first-choice mirror - if: matrix.scenario == 'slow-mirror' - run: echo '40.81.13.82 azure.archive.ubuntu.com' | sudo tee -a /etc/hosts + # the first list is the runner image's, with the degraded westus mirror + - name: Stall the first mirror list + if: matrix.scenario == 'stalled-first' + run: | + echo '40.81.13.82 azure.archive.ubuntu.com' | sudo tee -a /etc/hosts + cp /etc/apt/apt-mirrors.txt .github/apt-mirrors.txt + printf '%s\tpriority:%s\n' https://archive.ubuntu.com/ubuntu/ 1 https://security.ubuntu.com/ubuntu/ 2 \ + | sudo tee /etc/apt/apt-mirrors.txt + + # limits downloads from Canonical's servers to 32 Mbit/s + - name: Slow down archive.ubuntu.com + if: matrix.scenario == 'slow-archive' + run: | + dev=$(ip route show default | awk '{ print $5; exit }') + sudo tc qdisc add dev "$dev" handle ffff: ingress + for net in 91.189.88.0/21 185.125.188.0/22; do + sudo tc filter add dev "$dev" parent ffff: protocol ip prio 1 u32 match ip src "$net" \ + police rate 32mbit burst 256k drop flowid :1 + done - name: vp run install-browsers timeout-minutes: 8 From ef867a5f4ea8f1e525826558d247e773c568d6ba Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Oct 2026 16:47:04 +0000 Subject: [PATCH 6/9] Compare archive.ubuntu.com downloads with and without pipelining Co-Authored-By: Claude Opus 5.5 --- .github/workflows/apt-diagnostics.yml | 88 ++++++++++----------------- 1 file changed, 32 insertions(+), 56 deletions(-) diff --git a/.github/workflows/apt-diagnostics.yml b/.github/workflows/apt-diagnostics.yml index 805c4a3c10..8c690ae89f 100644 --- a/.github/workflows/apt-diagnostics.yml +++ b/.github/workflows/apt-diagnostics.yml @@ -1,4 +1,4 @@ -# Temporary: checks that `vp run install-browsers` succeeds quickly across runners. +# Temporary: compares downloads from archive.ubuntu.com with and without pipelining. # Removed before merging. name: apt diagnostics @@ -12,78 +12,54 @@ defaults: shell: bash jobs: - install-browsers: - name: install-browsers (${{ matrix.scenario }} ${{ matrix.sample }}) + archive: + name: archive (pipelining ${{ matrix.pipelining }} ${{ matrix.sample }}) runs-on: ubuntu-latest - timeout-minutes: 15 + timeout-minutes: 12 - permissions: - contents: read # check out the repository + permissions: {} strategy: fail-fast: false matrix: - scenario: [ci] - sample: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] - include: - - { scenario: stalled-first, sample: 1 } - - { scenario: stalled-first, sample: 2 } - - { scenario: stalled-first, sample: 3 } - - { scenario: slow-archive, sample: 1 } - - { scenario: slow-archive, sample: 2 } - - { scenario: slow-archive, sample: 3 } + pipelining: [on, off] + sample: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: voidzero-dev/setup-vp@68f39c78aaf39be468cabd2afb09c162574c84af # v1.21.2 - with: - run-install: false - - - run: vp install --frozen-lockfile - - - run: shellcheck .github/install-browsers.sh - if: matrix.scenario == 'ci' && matrix.sample == 1 - continue-on-error: true - - # the first list is the runner image's, with the degraded westus mirror - - name: Stall the first mirror list - if: matrix.scenario == 'stalled-first' + - name: Configure apt run: | - echo '40.81.13.82 azure.archive.ubuntu.com' | sudo tee -a /etc/hosts - cp /etc/apt/apt-mirrors.txt .github/apt-mirrors.txt printf '%s\tpriority:%s\n' https://archive.ubuntu.com/ubuntu/ 1 https://security.ubuntu.com/ubuntu/ 2 \ | sudo tee /etc/apt/apt-mirrors.txt + if [ "$PIPELINING" = on ]; then + echo 'Acquire::https::Pipeline-Depth "10";' | sudo tee /etc/apt/apt.conf + fi + echo 'APT::Get::Download-Only "true";' | sudo tee /etc/apt/apt.conf.d/download-only + env: + PIPELINING: ${{ matrix.pipelining }} - # limits downloads from Canonical's servers to 32 Mbit/s - - name: Slow down archive.ubuntu.com - if: matrix.scenario == 'slow-archive' + - name: Start TCP monitor run: | - dev=$(ip route show default | awk '{ print $5; exit }') - sudo tc qdisc add dev "$dev" handle ffff: ingress - for net in 91.189.88.0/21 185.125.188.0/22; do - sudo tc filter add dev "$dev" parent ffff: protocol ip prio 1 u32 match ip src "$net" \ - police rate 32mbit burst 256k drop flowid :1 - done + sudo setsid bash -c ' + while :; do + echo "@ $(date -u +%T.%N | cut -c1-12)" + ss -tinpH state established "( dport = :443 )" + sleep 1 + done' > /tmp/ss.log 2>&1 < /dev/null & - - name: vp run install-browsers - timeout-minutes: 8 + - name: Download + timeout-minutes: 6 run: | start=$(date +%s) - vp run install-browsers 2>&1 | tee /tmp/install.log - echo "RESULT scenario=${SCENARIO} seconds=$(($(date +%s) - start))" + npx --yes playwright@1.64.1 install-deps 2>&1 | tee /tmp/install.log + echo "RESULT pipelining=${PIPELINING} seconds=$(($(date +%s) - start))" env: - CI: true - SCENARIO: ${{ matrix.scenario }} + PIPELINING: ${{ matrix.pipelining }} - name: Summarize apt transfers if: always() - run: | - grep -E '^(Fetched|Need to get|Download complete|Err|Ign|W:|E:)' /tmp/install.log || true - echo "SWITCHES $(grep -c '^::warning::' /tmp/install.log || true)" - # which mirror served the files - grep -oE '^(Get|Hit):[0-9]+ [a-z]+://[^/ ]+' /tmp/install.log | cut -d' ' -f2 | sort | uniq -c || true - dig +noall +answer azure.archive.ubuntu.com - echo "LEFTOVER $(pgrep -c -x apt-get || true) apt-get processes" + run: grep -E '^(Fetched|Need to get|Download complete|Err|Ign|W:|E:)' /tmp/install.log || true + + # each second, the connections of apt's https method, and their TCP info + - name: TCP connections of apt's https method + if: always() + run: awk '/^@/ { t = $2; next } /"https",/ { print t, $0; getline; print t, $0 }' /tmp/ss.log From 5ca87d2fefa50bd6740c889cfc442c54f1f58266 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Oct 2026 16:52:33 +0000 Subject: [PATCH 7/9] Allow up to 5 stalled attempts Co-Authored-By: Claude Opus 5.5 --- .github/install-browsers.sh | 4 +- .github/workflows/apt-diagnostics.yml | 88 +++++++++++++++++---------- 2 files changed, 58 insertions(+), 34 deletions(-) diff --git a/.github/install-browsers.sh b/.github/install-browsers.sh index 81c52d8da7..71d461d652 100644 --- a/.github/install-browsers.sh +++ b/.github/install-browsers.sh @@ -14,7 +14,7 @@ cp /etc/apt/apt-mirrors.txt "${mirror_lists[1]}" # https://github.com/actions/runner-images/issues/14823 # Instead, Playwright's `apt-get install` only downloads the packages here, in attempts of 30 seconds, # as they normally take about 10. After an attempt that downloads less than 10 MB, the next one switches -# between .github/apt-mirrors.txt and the runner image's mirrors, and the third such attempt fails. +# between .github/apt-mirrors.txt and the runner image's mirrors, and the fifth such attempt fails. # Each attempt keeps the packages that the previous ones downloaded, and stopping one can't interrupt dpkg. echo 'APT::Get::Download-Only "true";' | sudo tee /etc/apt/apt.conf.d/download-only > /dev/null list=0 @@ -30,7 +30,7 @@ while true; do sudo pkill -KILL -x apt-get || true while pgrep -x apt-get > /dev/null; do sleep 1; done if (($(sudo du -sm /var/cache/apt/archives | cut -f1) - downloaded < 10)); then - if ((++stalls == 3)); then + if ((++stalls == 5)); then exit 1 fi list=$((1 - list)) diff --git a/.github/workflows/apt-diagnostics.yml b/.github/workflows/apt-diagnostics.yml index 8c690ae89f..ba98d7be8f 100644 --- a/.github/workflows/apt-diagnostics.yml +++ b/.github/workflows/apt-diagnostics.yml @@ -1,4 +1,4 @@ -# Temporary: compares downloads from archive.ubuntu.com with and without pipelining. +# Temporary: checks that `vp run install-browsers` succeeds quickly across runners. # Removed before merging. name: apt diagnostics @@ -12,54 +12,78 @@ defaults: shell: bash jobs: - archive: - name: archive (pipelining ${{ matrix.pipelining }} ${{ matrix.sample }}) + install-browsers: + name: install-browsers (${{ matrix.scenario }} ${{ matrix.sample }}) runs-on: ubuntu-latest - timeout-minutes: 12 + timeout-minutes: 15 - permissions: {} + permissions: + contents: read # check out the repository strategy: fail-fast: false matrix: - pipelining: [on, off] - sample: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + scenario: [ci] + sample: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] + include: + - { scenario: stalled-first, sample: 1 } + - { scenario: stalled-first, sample: 2 } + - { scenario: slow-archive, sample: 1 } + - { scenario: slow-archive, sample: 2 } steps: - - name: Configure apt + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: voidzero-dev/setup-vp@68f39c78aaf39be468cabd2afb09c162574c84af # v1.21.2 + with: + run-install: false + + - run: vp install --frozen-lockfile + + - run: shellcheck .github/install-browsers.sh + if: matrix.scenario == 'ci' && matrix.sample == 1 + continue-on-error: true + + # the first list is the runner image's, with the degraded westus mirror + - name: Stall the first mirror list + if: matrix.scenario == 'stalled-first' run: | + echo '40.81.13.82 azure.archive.ubuntu.com' | sudo tee -a /etc/hosts + cp /etc/apt/apt-mirrors.txt .github/apt-mirrors.txt printf '%s\tpriority:%s\n' https://archive.ubuntu.com/ubuntu/ 1 https://security.ubuntu.com/ubuntu/ 2 \ | sudo tee /etc/apt/apt-mirrors.txt - if [ "$PIPELINING" = on ]; then - echo 'Acquire::https::Pipeline-Depth "10";' | sudo tee /etc/apt/apt.conf - fi - echo 'APT::Get::Download-Only "true";' | sudo tee /etc/apt/apt.conf.d/download-only - env: - PIPELINING: ${{ matrix.pipelining }} - - name: Start TCP monitor + # limits downloads from Canonical's servers to 32 Mbit/s + - name: Slow down archive.ubuntu.com + if: matrix.scenario == 'slow-archive' run: | - sudo setsid bash -c ' - while :; do - echo "@ $(date -u +%T.%N | cut -c1-12)" - ss -tinpH state established "( dport = :443 )" - sleep 1 - done' > /tmp/ss.log 2>&1 < /dev/null & + dev=$(ip route show default | awk '{ print $5; exit }') + sudo tc qdisc add dev "$dev" handle ffff: ingress + prio=1 + for net in 91.189.88.0/21 185.125.188.0/22; do + sudo tc filter add dev "$dev" parent ffff: protocol ip prio "$prio" u32 match ip src "$net" \ + police rate 32mbit burst 256k drop flowid :1 + prio=$((prio + 1)) + done - - name: Download - timeout-minutes: 6 + - name: vp run install-browsers + timeout-minutes: 8 run: | start=$(date +%s) - npx --yes playwright@1.64.1 install-deps 2>&1 | tee /tmp/install.log - echo "RESULT pipelining=${PIPELINING} seconds=$(($(date +%s) - start))" + vp run install-browsers 2>&1 | tee /tmp/install.log + echo "RESULT scenario=${SCENARIO} seconds=$(($(date +%s) - start))" env: - PIPELINING: ${{ matrix.pipelining }} + CI: true + SCENARIO: ${{ matrix.scenario }} - name: Summarize apt transfers if: always() - run: grep -E '^(Fetched|Need to get|Download complete|Err|Ign|W:|E:)' /tmp/install.log || true - - # each second, the connections of apt's https method, and their TCP info - - name: TCP connections of apt's https method - if: always() - run: awk '/^@/ { t = $2; next } /"https",/ { print t, $0; getline; print t, $0 }' /tmp/ss.log + run: | + grep -E '^(Fetched|Need to get|Download complete|Err|Ign|W:|E:)' /tmp/install.log || true + echo "SWITCHES $(grep -c '^::warning::' /tmp/install.log || true)" + # which mirror served the files + grep -oE '^(Get|Hit):[0-9]+ [a-z]+://[^/ ]+' /tmp/install.log | cut -d' ' -f2 | sort | uniq -c || true + dig +noall +answer azure.archive.ubuntu.com + echo "LEFTOVER $(pgrep -c -x apt-get || true) apt-get processes" From e50bbd09834f3af59facc44c012e8e78a6c3b56e Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Oct 2026 16:57:53 +0000 Subject: [PATCH 8/9] Throttle archive.ubuntu.com with iptables in the verification Co-Authored-By: Claude Opus 5.5 --- .github/workflows/apt-diagnostics.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/apt-diagnostics.yml b/.github/workflows/apt-diagnostics.yml index ba98d7be8f..215d50a705 100644 --- a/.github/workflows/apt-diagnostics.yml +++ b/.github/workflows/apt-diagnostics.yml @@ -24,12 +24,13 @@ jobs: fail-fast: false matrix: scenario: [ci] - sample: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] + sample: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] include: - { scenario: stalled-first, sample: 1 } - { scenario: stalled-first, sample: 2 } - { scenario: slow-archive, sample: 1 } - { scenario: slow-archive, sample: 2 } + - { scenario: slow-archive, sample: 3 } steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -55,18 +56,15 @@ jobs: printf '%s\tpriority:%s\n' https://archive.ubuntu.com/ubuntu/ 1 https://security.ubuntu.com/ubuntu/ 2 \ | sudo tee /etc/apt/apt-mirrors.txt - # limits downloads from Canonical's servers to 32 Mbit/s + # drops packets from Canonical's servers above 1500 per second, about 2 MB/s - name: Slow down archive.ubuntu.com if: matrix.scenario == 'slow-archive' run: | - dev=$(ip route show default | awk '{ print $5; exit }') - sudo tc qdisc add dev "$dev" handle ffff: ingress - prio=1 for net in 91.189.88.0/21 185.125.188.0/22; do - sudo tc filter add dev "$dev" parent ffff: protocol ip prio "$prio" u32 match ip src "$net" \ - police rate 32mbit burst 256k drop flowid :1 - prio=$((prio + 1)) + sudo iptables -A INPUT -s "$net" -m hashlimit --hashlimit-above 1500/sec --hashlimit-burst 1500 \ + --hashlimit-mode srcip --hashlimit-name "canonical-${net%%.*}" -j DROP done + sudo iptables -L INPUT -n -v - name: vp run install-browsers timeout-minutes: 8 From ee1b2bd2197b4cd0b20df874c55bc2a0730d1730 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 27 Oct 2026 17:03:51 +0000 Subject: [PATCH 9/9] Remove the temporary apt diagnostics workflow, and polish the comments Co-Authored-By: Claude Opus 5.5 --- .github/apt.conf | 2 +- .github/install-browsers.sh | 6 +- .github/workflows/apt-diagnostics.yml | 87 --------------------------- 3 files changed, 4 insertions(+), 91 deletions(-) delete mode 100644 .github/workflows/apt-diagnostics.yml diff --git a/.github/apt.conf b/.github/apt.conf index 5ab133f795..878f2c4996 100644 --- a/.github/apt.conf +++ b/.github/apt.conf @@ -2,6 +2,6 @@ // so it overrides the runner image's settings. // The runner image turns off pipelining, so each package costs a round trip, -// and downloading them from archive.ubuntu.com takes 5 times longer. +// and downloading them from archive.ubuntu.com takes several times longer. // No proxy can break pipelining over HTTPS. Acquire::https::Pipeline-Depth "10"; diff --git a/.github/install-browsers.sh b/.github/install-browsers.sh index 71d461d652..809ad89fac 100644 --- a/.github/install-browsers.sh +++ b/.github/install-browsers.sh @@ -4,10 +4,8 @@ set -euo pipefail echo '::group::Install browsers' -# see the comments in these files +# see the comment in this file sudo cp .github/apt.conf /etc/apt/apt.conf -mirror_lists=(.github/apt-mirrors.txt "$(mktemp)") -cp /etc/apt/apt-mirrors.txt "${mirror_lists[1]}" # apt only moves on to the next mirror in /etc/apt/apt-mirrors.txt after an error, # so any mirror that keeps sending data, however slowly, stalls it: @@ -16,6 +14,8 @@ cp /etc/apt/apt-mirrors.txt "${mirror_lists[1]}" # as they normally take about 10. After an attempt that downloads less than 10 MB, the next one switches # between .github/apt-mirrors.txt and the runner image's mirrors, and the fifth such attempt fails. # Each attempt keeps the packages that the previous ones downloaded, and stopping one can't interrupt dpkg. +mirror_lists=(.github/apt-mirrors.txt "$(mktemp)") +cp /etc/apt/apt-mirrors.txt "${mirror_lists[1]}" echo 'APT::Get::Download-Only "true";' | sudo tee /etc/apt/apt.conf.d/download-only > /dev/null list=0 stalls=0 diff --git a/.github/workflows/apt-diagnostics.yml b/.github/workflows/apt-diagnostics.yml deleted file mode 100644 index 215d50a705..0000000000 --- a/.github/workflows/apt-diagnostics.yml +++ /dev/null @@ -1,87 +0,0 @@ -# Temporary: checks that `vp run install-browsers` succeeds quickly across runners. -# Removed before merging. -name: apt diagnostics - -on: - pull_request: - -permissions: {} - -defaults: - run: - shell: bash - -jobs: - install-browsers: - name: install-browsers (${{ matrix.scenario }} ${{ matrix.sample }}) - runs-on: ubuntu-latest - timeout-minutes: 15 - - permissions: - contents: read # check out the repository - - strategy: - fail-fast: false - matrix: - scenario: [ci] - sample: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] - include: - - { scenario: stalled-first, sample: 1 } - - { scenario: stalled-first, sample: 2 } - - { scenario: slow-archive, sample: 1 } - - { scenario: slow-archive, sample: 2 } - - { scenario: slow-archive, sample: 3 } - - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: voidzero-dev/setup-vp@68f39c78aaf39be468cabd2afb09c162574c84af # v1.21.2 - with: - run-install: false - - - run: vp install --frozen-lockfile - - - run: shellcheck .github/install-browsers.sh - if: matrix.scenario == 'ci' && matrix.sample == 1 - continue-on-error: true - - # the first list is the runner image's, with the degraded westus mirror - - name: Stall the first mirror list - if: matrix.scenario == 'stalled-first' - run: | - echo '40.81.13.82 azure.archive.ubuntu.com' | sudo tee -a /etc/hosts - cp /etc/apt/apt-mirrors.txt .github/apt-mirrors.txt - printf '%s\tpriority:%s\n' https://archive.ubuntu.com/ubuntu/ 1 https://security.ubuntu.com/ubuntu/ 2 \ - | sudo tee /etc/apt/apt-mirrors.txt - - # drops packets from Canonical's servers above 1500 per second, about 2 MB/s - - name: Slow down archive.ubuntu.com - if: matrix.scenario == 'slow-archive' - run: | - for net in 91.189.88.0/21 185.125.188.0/22; do - sudo iptables -A INPUT -s "$net" -m hashlimit --hashlimit-above 1500/sec --hashlimit-burst 1500 \ - --hashlimit-mode srcip --hashlimit-name "canonical-${net%%.*}" -j DROP - done - sudo iptables -L INPUT -n -v - - - name: vp run install-browsers - timeout-minutes: 8 - run: | - start=$(date +%s) - vp run install-browsers 2>&1 | tee /tmp/install.log - echo "RESULT scenario=${SCENARIO} seconds=$(($(date +%s) - start))" - env: - CI: true - SCENARIO: ${{ matrix.scenario }} - - - name: Summarize apt transfers - if: always() - run: | - grep -E '^(Fetched|Need to get|Download complete|Err|Ign|W:|E:)' /tmp/install.log || true - echo "SWITCHES $(grep -c '^::warning::' /tmp/install.log || true)" - # which mirror served the files - grep -oE '^(Get|Hit):[0-9]+ [a-z]+://[^/ ]+' /tmp/install.log | cut -d' ' -f2 | sort | uniq -c || true - dig +noall +answer azure.archive.ubuntu.com - echo "LEFTOVER $(pgrep -c -x apt-get || true) apt-get processes"