File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments