Skip to content

Commit 519f737

Browse files
committed
Use Azure mirrors of Ubuntu .deb repositories in containers.
This reduces the likelihood of spurious CI failures caused by DDoS filters being triggered by massive numbers of concurrent CI jobs.
1 parent dc9e2a7 commit 519f737

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,22 @@ jobs:
329329
echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV
330330
if [ -f "/etc/debian_version" ]
331331
then
332+
# Use Azure APT mirrors in containers to avoid HTTP errors due to DDoS filters triggered by lots of CI jobs launching concurrently.
333+
# Note that not all Ubuntu versions support "mirror+file:..." URIs in APT sources, so just use Azure mirrors exclusively.
334+
# Note also that on recent Ubuntu versions DEB822 format is used for source files.
335+
APT_SOURCES=()
336+
if [ -d "/etc/apt/sources.list.d" ]
337+
then
338+
readarray -t APT_SOURCES < <(find "/etc/apt/sources.list.d" -type f -name '*.sources' -print)
339+
fi
340+
if [ -f "/etc/apt/sources.list" ]
341+
then
342+
APT_SOURCES+=("/etc/apt/sources.list")
343+
fi
344+
if [ "${#APT_SOURCES[@]}" -gt 0 ]
345+
then
346+
sed -i -E -e 's!([^ ]+) (http|https)://(archive|security)\.ubuntu\.com/ubuntu[^ ]*(.*)!\1 http://azure.archive.ubuntu.com/ubuntu/\4!' "${APT_SOURCES[@]}"
347+
fi
332348
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
333349
if [ "$(apt-cache search "^python-is-python3$" | wc -l)" -ne 0 ]
334350
then

0 commit comments

Comments
 (0)