Skip to content

Commit e67ba43

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 782f1b1 commit e67ba43

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

0 commit comments

Comments
 (0)