From 709a9bdefb7a6d9e360b00d7de4d9ced2463cee8 Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 11 Nov 2026 06:35:34 -0800 Subject: [PATCH] ci: fail over unavailable Ubuntu package mirrors --- .../scripts/install-ubuntu-apt-packages.sh | 32 +++++++++++++++++++ .github/workflows/e2e.yml | 4 +++ .github/workflows/pr.yml | 10 +----- 3 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 .github/scripts/install-ubuntu-apt-packages.sh diff --git a/.github/scripts/install-ubuntu-apt-packages.sh b/.github/scripts/install-ubuntu-apt-packages.sh new file mode 100644 index 00000000000..f0beef866d3 --- /dev/null +++ b/.github/scripts/install-ubuntu-apt-packages.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -eq 0 ]; then + echo 'Usage: install-ubuntu-apt-packages.sh ...' >&2 + exit 2 +fi + +bash "$(dirname "${BASH_SOURCE[0]}")/prepare-ubuntu-apt.sh" + +# Both routes and diagnostics fit the previous seven-minute package setup budget. +if timeout 45 sudo apt-get update && timeout 120 sudo apt-get install -y "$@"; then + exit 0 +fi + +echo 'Ubuntu package setup failed; trying the same packages through the MIT mirror.' >&2 +for host in archive.ubuntu.com ports.ubuntu.com mirrors.mit.edu; do + timeout 5 getent ahosts "$host" || true +done + +# Change repository locations while retaining suites, architectures and signing keys. +for source in /etc/apt/apt-mirrors.txt /etc/apt/sources.list /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources; do + if [ -f "$source" ]; then + sudo sed -i -E \ + -e 's#https?://(azure\.archive|archive|security)\.ubuntu\.com/ubuntu#https://mirrors.mit.edu/ubuntu#g' \ + -e 's#https?://ports\.ubuntu\.com/ubuntu-ports#https://mirrors.mit.edu/ubuntu-ports#g' \ + "$source" + fi +done + +timeout 60 sudo apt-get update +timeout 180 sudo apt-get install -y "$@" diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 9339215a217..9c823cb4aae 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -123,6 +123,10 @@ jobs: exit 0 fi read -r -a packages <<< "$ORCA_E2E_APT_PACKAGES" + if [ -f .github/scripts/install-ubuntu-apt-packages.sh ]; then + bash .github/scripts/install-ubuntu-apt-packages.sh "${packages[@]}" + exit 0 + fi if [ -f .github/scripts/prepare-ubuntu-apt.sh ]; then bash .github/scripts/prepare-ubuntu-apt.sh else diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index bd71e39e97a..d123500b251 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -790,15 +790,7 @@ jobs: id: shells background: true run: | - # Per-connection limits complement the whole-command apt deadlines below. - sudo tee /etc/apt/apt.conf.d/99-orca-shell-contracts >/dev/null <<'APTCONF' - Acquire::http::Timeout "15"; - Acquire::https::Timeout "15"; - Acquire::Retries "1"; - APTCONF - # Unrelated runner repositories may fail refresh; installing zsh must still succeed. - timeout 120 sudo apt-get update || true - timeout 300 sudo apt-get install -y zsh + bash .github/scripts/install-ubuntu-apt-packages.sh zsh # A fixed 4.x release meets the contract without tracking package-repository updates. case "$(uname -m)" in aarch64) arch=aarch64 sha=57349f0111728c64b703a84e611aa97ff4d1fa8466385d64e67bd5bc3ffa49fc ;;