Skip to content

Hotfix: demote azure.archive.ubuntu.com mirror priority, add apt acquire timeouts - #14596

Open
v-AndriiKhyliuk with Copilot wants to merge 2 commits into
mainfrom
copilot/hotfix-demote-azure-mirror-priority
Open

v-AndriiKhyliuk with Copilot wants to merge 2 commits into
mainfrom
copilot/hotfix-demote-azure-mirror-priority

Conversation

Copilot AI commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Incident #5183: apt-get update/apt-get install hung for up to 6 hours on Ubuntu runner images because azure.archive.ubuntu.com was configured as the highest-priority apt mirror and stalled mid-transfer (TCP connects, then hangs) rather than failing cleanly. The existing retry wrapper in configure-apt-mock.sh only fires on stderr pattern matches after process exit, so a silent hang never triggers a retry or fallback to a healthier mirror.

This hotfix demotes azure to lowest priority (kept as fallback, not removed) and adds an explicit apt timeout as a second line of defense — minimal, low-risk change to unblock the fleet ahead of a deeper retry/timeout rework.

Mirror priority reorder

  • images/ubuntu/scripts/build/configure-apt-sources.sh and images/ubuntu-slim/scripts/build/configure-apt-sources.sh: archive.ubuntu.com → priority:1, security.ubuntu.com → priority:2, azure.archive.ubuntu.com → priority:3 (was priority:1)

Acquire timeout (defense-in-depth)

  • images/ubuntu/scripts/build/configure-apt.sh and images/ubuntu-slim/scripts/build/configure-apt.sh: new /etc/apt/apt.conf.d/81-timeouts, alongside existing 80-retries, bounding a stalled mirror connection instead of letting it hang indefinitely:
Acquire::http::Timeout "30";
Acquire::https::Timeout "30";

configure-apt-mock.sh's retry wrapper is untouched — that rework is tracked separately.

Check list

  • Related issue / work item is attached
  • Tests are written (if applicable)
  • Documentation is updated (if applicable)
  • Changes are tested and related VM images are successfully generated

Copilot AI changed the title [WIP] Fix priority of Azure mirror in apt sources Hotfix: demote azure.archive.ubuntu.com mirror priority, add apt acquire timeouts Aug 19, 2026
Copilot AI requested a review from v-AndriiKhyliuk August 19, 2026 19:22
@v-AndriiKhyliuk
v-AndriiKhyliuk marked this pull request as ready for review August 19, 2026 19:23
Copilot AI lite review requested due to automatic review settings August 19, 2026 19:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This hotfix reduces the chance of Ubuntu image builds (and downstream user workflows) hanging indefinitely or selecting an unhealthy apt mirror by (1) demoting azure.archive.ubuntu.com to lowest mirror priority and (2) adding explicit apt acquire timeouts as a fail-fast safeguard.

Changes:

  • Reordered /etc/apt/apt-mirrors.txt priorities so archive.ubuntu.com and security.ubuntu.com are preferred over azure.archive.ubuntu.com.
  • Added /etc/apt/apt.conf.d/81-timeouts to bound HTTP/HTTPS acquire operations to 30 seconds, preventing silent hangs on stalled connections.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
images/ubuntu/scripts/build/configure-apt.sh Adds apt acquire timeouts via a new 81-timeouts config file.
images/ubuntu/scripts/build/configure-apt-sources.sh Reorders mirror priorities to prefer upstream Ubuntu mirrors over Azure.
images/ubuntu-slim/scripts/build/configure-apt.sh Adds the same apt acquire timeouts for slim images.
images/ubuntu-slim/scripts/build/configure-apt-sources.sh Reorders mirror priorities similarly for slim images.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

gr2m added a commit to vercel/ai that referenced this pull request Aug 19, 2026
## Background

The Test RSC e2e job failed three times on August 19 while Playwright
installed Chromium system dependencies:

- https://github.com/vercel/ai/actions/runs/32226175669/job/95987241660
- https://github.com/vercel/ai/actions/runs/32296621196/job/96210594834
- https://github.com/vercel/ai/actions/runs/32302334578/job/96228309554

In each run, apt-get update stalled against azure.archive.ubuntu.com
until the 15-minute timeout. Playwright had spawned apt-get through a
nested sudo process, so apt-get survived the timeout and retained
/var/lib/apt/lists/lock. The retry guard only watched
/var/lib/dpkg/lock-frontend, causing attempts two and three to fail
immediately.

This matches the active GitHub runner-images incident:
actions/runner-images#14594

## Summary

- run Playwright and its timeout as root so apt-get remains in the
timeout process group
- add apt acquisition timeouts and a bounded retry so stalled mirrors
fail over promptly
- wait for the apt lists, archives, and dpkg locks before every attempt
- report an explicit error if locks remain held for five minutes

## End-to-End Verification

This is a CI-only change. The intermittent mirror timeout cannot be
forced locally; this pull request CI exercises the normal Test RSC e2e
path. The timeout path now keeps the Playwright process and its
privileged apt descendants in one process group and checks the exact
lock observed in all three failures before retrying.

## Validation

- pnpm check
- pnpm type-check:full
- workflow YAML parsing
- embedded Bash syntax check
- git diff --check

## Checklist

- [x] All commits are signed (PRs with unsigned commits cannot be
merged)
- [ ] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [ ] A patch changeset for relevant packages has been added (for bug
fixes / features - run pnpm changeset in the project root)
- [x] I have reviewed this pull request (self-review)

## Related Issues

- actions/runner-images#14594
- actions/runner-images#14596
bghgary added a commit to bghgary/arcana.cpp that referenced this pull request Aug 19, 2026
The runner image deliberately sets APT::Acquire::Retries 10; overriding it to 1
trades resilience against ordinary transient failures for a faster fail in one
pathological case. actions/runner-images#14596 fixes the root cause image-side
by demoting the azure mirror, which a workflow cannot do. timeout-minutes
already bounds the hang, and it bounds every other hang too.

Co-authored-by: Copilot App <[email protected]>
printf "http://azure.archive.ubuntu.com/ubuntu/\tpriority:1\n" | tee -a /etc/apt/apt-mirrors.txt
printf "https://archive.ubuntu.com/ubuntu/\tpriority:2\n" | tee -a /etc/apt/apt-mirrors.txt
printf "https://security.ubuntu.com/ubuntu/\tpriority:3\n" | tee -a /etc/apt/apt-mirrors.txt
printf "https://archive.ubuntu.com/ubuntu/\tpriority:1\n" | tee -a /etc/apt/apt-mirrors.txt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to have https here? Intuitively yes but there are mixed opinions on this matter and previously out top pick used plain http. And https for Ubuntu archives was added not long ago.

@@ -17,6 +17,10 @@ systemctl disable apt-daily-upgrade.service
# Enable retry logic for apt up to 10 times
echo "APT::Acquire::Retries \"10\";" > /etc/apt/apt.conf.d/80-retries

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APT::Acquire::Retries

Copilot claims that it's Acquire::Retries and by setting this parameter incorrectly we leave it with default 3 retries. Is there a way to confirm that?

@Zordrak Zordrak mentioned this pull request Aug 24, 2026
3 of 16 tasks
cderv added a commit to quarto-dev/quarto-cli that referenced this pull request Oct 27, 2026
A degraded node in the azure.archive.ubuntu.com pool serves package
indexes at full speed but archives at tens of kB/s. The runner images
set apt timeouts that only catch a full stall, so apt never moves to
archive.ubuntu.com. The Playwright dependency step then hits its 15
minute limit and setup-r takes about 20 minutes. The Azure line is
dropped from apt-mirrors.txt only when the mirror is measured slow, so
healthy runs keep using it.

- Sample one .deb from the Azure mirror before setup-r, whose apt
  calls cannot be wrapped, and drop the mirror when it stays under
  1 MB/s for 10 seconds
- Run the later apt steps through a helper that gives each attempt
  3 minutes, drops the mirror after a failure, and retries
- Run dpkg --configure -a before each retry, in case a timeout
  interrupted an install (not exercised by the probes)

The logic is inline in test-smokes.yml rather than a local composite
action, because release mode checks out older tags that lack the
action directory.

See #15186 (job that hit the 15 minute limit),
actions/runner-images#14823, and actions/runner-images#14596.
cderv added a commit to quarto-dev/quarto-cli that referenced this pull request Oct 27, 2026
…15204)

A degraded node in the azure.archive.ubuntu.com pool serves package
indexes at full speed but archives at tens of kB/s. The runner images
set apt timeouts that only catch a full stall, so apt never moves to
archive.ubuntu.com. The Playwright dependency step then hits its 15
minute limit and setup-r takes about 20 minutes. The Azure line is
dropped from apt-mirrors.txt only when the mirror is measured slow, so
healthy runs keep using it.

- Sample one .deb from the Azure mirror before setup-r, whose apt
  calls cannot be wrapped, and drop the mirror when it stays under
  1 MB/s for 10 seconds
- Run the later apt steps through a helper that gives each attempt
  3 minutes, drops the mirror after a failure, and retries
- Run dpkg --configure -a before each retry, in case a timeout
  interrupted an install (not exercised by the probes)

The logic is inline in test-smokes.yml rather than a local composite
action, because release mode checks out older tags that lack the
action directory.

See #15186 (job that hit the 15 minute limit),
actions/runner-images#14823, and actions/runner-images#14596.

(cherry picked from commit 1d82b12)
nstepien added a commit to Comcast/react-data-grid that referenced this pull request Oct 27, 2026
`playwright install --no-shell --with-deps` kept the `vp run ci` step
from finishing within its 6 minutes in 46 of the 237 CI attempts from
2026-10-21 to 10-27. All of them ran on runners in Azure's `westus` (12
of 21 attempts) and `westus3` (34 of 46) regions. None of the 170
attempts in other regions hung.

#### Why apt hung

GitHub's Ubuntu images list `azure.archive.ubuntu.com` first in
`/etc/apt/apt-mirrors.txt`. It resolves to a mirror in the runner's
region, like `cloud-mirror-lb.westus3.cloudapp.azure.com`. The `westus`
and `westus3` mirrors serve the package lists quickly, but relay the
packages through a Squid proxy that almost always misses its cache
(`X-Cache: MISS from 192.168.0.4`, `Via: 1.1 192.168.0.4 (squid/5.2)`),
at 40–60 kB/s, so the 119 MB of packages would take about 40 minutes. In
a job that I let run for 15 minutes, apt downloaded 47 of the ~190
packages.

apt only moves on to the next mirror after an error, and
`Acquire::http::Timeout` only fires when no data arrives for that long.
Data arrived every 5–90 ms, so apt never timed out, or tried
`archive.ubuntu.com`, the next mirror in the list. This is
actions/runner-images#14823, open since 2026-09-30.

`.github/apt.conf`'s retries and timeouts never applied either, as the
image's `/etc/apt/apt.conf.d/zz-retries` sorts after the `99-ci` that we
copied it to. Only its `quiet "2"` applied, which hid where apt was
stuck.

The other mirrors slow down at times too. In one sample,
archive.ubuntu.com downloaded at under 0.5 MB/s for 4 of 14 jobs running
at the same time, and in another, the `eastus` mirror was slow for all 6
jobs that ran there. A different mirror order alone would only move the
problem.

#### Changes

- On CI, the `install-browsers` task runs `.github/install-browsers.sh`.
It runs Playwright's `apt-get install` in download-only mode, in
attempts of 30 seconds, as the downloads normally take about 10. After
an attempt that downloads less than 10 MB, the next one switches between
`archive.ubuntu.com` (`.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. `playwright install
--no-shell --with-deps` then installs them, so the time limit can't
interrupt dpkg.
- The downloads start from `archive.ubuntu.com`, as in GitHub's proposed
hotfix, actions/runner-images#14596.
- `.github/apt.conf` turns on pipelining over HTTPS, which the image
turns off. Downloading the packages from archive.ubuntu.com took 5–16 s
with it (median 8.5 s) and 23–169 s without it (median 60.5 s), in 10
jobs each that ran at the same time. It's now installed as
`/etc/apt/apt.conf`, which apt reads after `/etc/apt/apt.conf.d/`. Its
ineffective retries and timeouts are gone, and so is `quiet "2"`, so the
log shows which mirror served each package, and how fast.
- When `timeout` stops Playwright, `sudo` only relays the signal to the
`sh` running apt-get, so the orphaned apt-get kept downloading and held
apt's locks, which failed the next attempt. The script kills it.

#### Results

I ran `vp run install-browsers` in 3 batches of 20 jobs with the final
script, and all 58 jobs that ran it succeeded (in the first batch, my
setup for 2 of them failed before they did):

- 46 jobs as in CI, 14 of them in `westus` or `westus3`: 42–128 s for
the whole task (median 54 s), against about 45 s before, when the Azure
mirror was healthy. 12 of them needed more than one attempt, because of
slow mirrors.
- 6 jobs whose first mirror list was the degraded `westus` mirror,
pinned in `/etc/hosts`: 68–156 s.
- 6 jobs that dropped archive.ubuntu.com's packets above 1500/s: 48–135
s.

CI passed on this PR's last commit, which ran in `westus`. Before the
fix, CI hung on this PR in `westus3`.

#### Upstream

actions/runner-images#14823 tracks the slow Azure mirrors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
bghgary added a commit to microsoft/arcana.cpp that referenced this pull request Nov 5, 2026
* Harden Linux apt step and add a ci-complete gate job

Bound apt's retries and transfer timeouts so a degraded in-datacenter mirror
fails fast instead of stalling silently for hours, and cap every job with
timeout-minutes so a future stall is a fast diagnosable failure rather than a
6h timeout.

Install clang-14 alone; clang++-14 is not a package name, so apt fell through
to regex matching and pulled in 20 packages where 2 were meant.

ci-complete aggregates the four jobs behind one stable check name that branch
protection can require, leaving the matrix-generated names free to change.
if: always() is required or the job is skipped when a dependency fails, and a
skipped required check satisfies the requirement.

Co-authored-by: Copilot App <[email protected]>

* Drop the per-repo apt workaround

The runner image deliberately sets APT::Acquire::Retries 10; overriding it to 1
trades resilience against ordinary transient failures for a faster fail in one
pathological case. actions/runner-images#14596 fixes the root cause image-side
by demoting the azure mirror, which a workflow cannot do. timeout-minutes
already bounds the hang, and it bounds every other hang too.

Co-authored-by: Copilot App <[email protected]>

---------

Co-authored-by: Gary Hsu <[email protected]>
Co-authored-by: Copilot App <[email protected]>

This branch has not been deployed

No deployments
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.

4 participants