Skip to content

CI: rank apt mirrors by speed so a slow Azure mirror cannot time out apt steps - #15350

Merged
danielhanchen merged 1 commit into
mainfrom
ci-apt-prefer-fast-mirror
Oct 26, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-apt-prefer-fast-mirror

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Why apt steps started timing out

Since about Oct 22, azure.archive.ubuntu.com on GitHub-hosted Ubuntu runners has been serving some runners at a few tens of KB/s for hours at a time (actions/runner-images#14823, #15040). The images send apt through mirror+file:/etc/apt/apt-mirrors.txt with the Azure mirror first, and apt only fails over to the next entry on an error. A slow transfer is still a live transfer, so Acquire::http::Timeout never fires and every retry in retry-with-apt-lock.sh downloads from the same slow node.

That is what killed the Tauri smoke build on staging: the 55 MB WebKitGTK install fetched at roughly 35 KB/s, both 360 s attempts were cut off, and the 15 minute step limit ended the job. A timed-out attempt also left its apt-get running under sudo, still holding the dpkg lock, so the second attempt opened with Could not get lock /var/lib/dpkg/lock-frontend.

Fix

All in .github/scripts/retry-with-apt-lock.sh, so every workflow that already goes through the helper picks it up:

  • Once per job, each mirror in apt-mirrors.txt is timed on a 5 s fetch of dists/<codename>/main/binary-<arch>/Packages.gz, and the file is rewritten fastest first. http://archive.ubuntu.com/ubuntu/ is added as a candidate beside an *.archive.ubuntu.com mirror; ports.ubuntu.com (arm64) is left alone. A healthy Azure mirror stays first, since it is normally the fastest.
  • After a failed attempt the leading mirror is moved last, so the retry goes somewhere else.
  • After a timed-out attempt, leftover apt-get / apt processes are stopped and dpkg --configure -a runs before the lock wait, so the retry does not start against a lock held by the previous attempt.
  • APT_PREFER_FAST_MIRROR=0 turns the mirror handling off. Without /etc/apt/apt-mirrors.txt or curl the helper behaves exactly as before.

Tests

  • New tests/studio/test_apt_mirror_preference.py runs the real helper against a temporary mirror file with sudo, curl, pkill, dpkg and fuser stubbed on PATH: fastest mirror first, a fast Azure mirror keeps its place, a failed attempt demotes the leader, ranking happens once per job, ports mirrors get no global archive, the opt-out and a missing mirror file leave things untouched.
  • test_apt_steps_are_bounded.py now counts the probe (up to 4 x 5 s per job) and the 2 s orphan stop in each step's worst case; every existing step budget still fits.
  • The probe URL returns 200 with the same 1.79 MB file on azure.archive.ubuntu.com, archive.ubuntu.com and security.ubuntu.com.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-26T10:08:00.757904Z
We couldn’t complete this review. Comment @codex review to try again.
0df7321 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant