Skip to content

Commit 2a0b753

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 0087a42 commit 2a0b753

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

0 commit comments

Comments
 (0)