Files
ols-nos/src/sonic-build-hooks/hooks/curl
Yevhen Fastiuk 52f6dd65a3 Improve remote fetch (#12795)
### Why I did it
To fix those errors:
One:
```
Connecting to urm.nvidia.com (urm.nvidia.com)|*.*.*.*|:443... connected.
GnuTLS: Error in the pull function.
Unable to establish SSL connection.
Error 4
make[1]: Leaving directory '/sonic/src/smartmontools'
[ target/debs/bullseye/smartmontools_6.6-1_amd64.deb ]
```
Second:
```
Get:90 https://debian-mirror-url buster/main amd64 librrd-dev amd64 1.7.1-2 [284 kB]
Get:91 https://debian-mirror-url buster/main amd64 psmisc amd64 23.2-1+deb10u1 [126 kB]
Get:92 https://debian-mirror-url buster/main amd64 python-smbus amd64 4.1-1 [12.2 kB]
Get:93 https://debian-mirror-url buster/main amd64 python3.7-dev amd64 3.7.3-2+deb10u3 [510 kB]
Get:94 https://debian-mirror-url buster/main amd64 python3-dev amd64 3.7.3-1 [1264 B]
Get:95 https://debian-mirror-url buster/main amd64 python3-smbus amd64 4.1-1 [12.5 kB]
Get:96 https://debian-mirror-url buster/main amd64 rrdtool amd64 1.7.1-2 [485 kB]
Fetched 122 MB in 12s (9976 kB/s)
E: Failed to fetch https://debian-mirror-url/pool/main/p/python-defaults/python2-minimal_2.7.16-1_amd64.deb  500  Internal Server Error [IP: *.*.*.* 443]
E: Failed to fetch https://debian-mirror-url/pool/main/f/fontconfig/fontconfig-config_2.13.1-2_all.deb  500  Internal Server Error [IP: *.*.*.* 443]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get update &&       apt-get install -y          build-essential         python3-dev             ipmitool                librrd8                 librrd-dev              rrdtool                 python-smbus            python3-smbus           dmidecode               i2c-tools               psmisc                  libpci3' returned a non-zero code: 100
[ target/docker-platform-monitor.gz ]
Error 1
```

#### How I did it
Add retry mechanism to apt, wget, and curl hooks
2023-09-23 18:07:04 -07:00

25 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
. /usr/local/share/buildinfo/scripts/buildinfo_base.sh
[ -z $REAL_COMMAND ] && REAL_COMMAND=/usr/bin/curl
# Retry if something super-weird has happened. Use --retry-connrefused and
# --retry options for curl.
# --retry-connrefused - Consider "connection refused" a transient error and try
# again. Normally wget/curl gives up on a URL when it is unable to connect to
# the site because failure to connect is taken as a sign that the server is not
# running at all and that retries would not help. This option is for mirroring
# unreliable sites whose servers tend to disappear for short periods of time.
# --retry - If a transient error is returned when curl tries to perform a
# transfer, it will retry this number of times before giving up. Transient error
# means either: a timeout, an FTP 4xx response code or an HTTP 408, 429, 500,
# 502, 503 or 504 response code.
REAL_COMMAND="$REAL_COMMAND --retry-connrefused --retry 5"
if [ "$SKIP_BUILD_HOOK" == y ]; then
$REAL_COMMAND "$@"
exit $?
fi
REAL_COMMAND=$REAL_COMMAND download_packages "$@"