Skip to content

Commit 53d0780

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 133df3b commit 53d0780

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)