[build] Add config to set pip http timeout (#16748)

Why I did it
Add config to set pip HTTP timeout value in building process for build to be more stable.
Default value is 60.

Work item tracking
Microsoft ADO (number only): 25190067
How I did it
Insert timeout options in all pip commands.
This commit is contained in:
Liu Shilong 2023-10-23 18:05:22 +08:00 committed by GitHub
parent c2edc6f9d5
commit 1eae34993e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 1 deletions

View File

@ -203,6 +203,7 @@ $(shell \
SONIC_VERSION_CACHE_SOURCE=$(SONIC_VERSION_CACHE_SOURCE) \
DBGOPT='$(DBGOPT)' \
MIRROR_SNAPSHOT=$(MIRROR_SNAPSHOT) \
PIP_HTTP_TIMEOUT=$(PIP_HTTP_TIMEOUT) \
scripts/generate_buildinfo_config.sh)
# Generate the slave Dockerfile, and prepare build info for it
@ -570,6 +571,7 @@ SONIC_BUILD_INSTRUCTION := $(MAKE) \
SONIC_VERSION_CONTROL_COMPONENTS=$(SONIC_VERSION_CONTROL_COMPONENTS) \
ONIE_IMAGE_PART_SIZE=$(ONIE_IMAGE_PART_SIZE) \
SONIC_OS_VERSION=$(SONIC_OS_VERSION) \
PIP_HTTP_TIMEOUT=$(PIP_HTTP_TIMEOUT) \
$(SONIC_OVERRIDE_BUILD_VARS)
.PHONY: sonic-slave-build sonic-slave-bash init reset
@ -592,6 +594,7 @@ export MIRROR_URLS
export MIRROR_SECURITY_URLS
export MIRROR_SNAPSHOT
export SONIC_VERSION_CONTROL_COMPONENTS
export PIP_HTTP_TIMEOUT
%:: | sonic-build-hooks
ifneq ($(filter y, $(MULTIARCH_QEMU_ENVIRON) $(CROSS_BUILD_ENVIRON)),)

View File

@ -311,3 +311,7 @@ GZ_COMPRESS_PROGRAM ?= gzip
# SONIC_OS_VERSION - sonic os version
SONIC_OS_VERSION ?= 11
# PIP timeout for http connection
PIP_HTTP_TIMEOUT ?= 60

View File

@ -12,3 +12,4 @@ echo "export SONIC_VERSION_CACHE=${SONIC_VERSION_CACHE}" >> $BUILDINFO_CONFIG
echo "export SONIC_VERSION_CACHE_SOURCE=${SONIC_VERSION_CACHE_SOURCE}" >> $BUILDINFO_CONFIG
echo "export DISTRO=${DISTRO}" >> $BUILDINFO_CONFIG
echo "export MIRROR_SNAPSHOT=$MIRROR_SNAPSHOT" >> $BUILDINFO_CONFIG
echo "export PIP_HTTP_TIMEOUT=$PIP_HTTP_TIMEOUT" >> $BUILDINFO_CONFIG

View File

@ -288,7 +288,7 @@ download_packages()
run_pip_command()
{
declare -a parameters=("$@")
declare -a parameters=("--default-timeout" "$PIP_HTTP_TIMEOUT" "$@")
PIP_CACHE_PATH=${PKG_CACHE_PATH}/pip
PKG_CACHE_OPTION="--cache-dir=${PIP_CACHE_PATH}"