stx: Fix-up for Kubernetes tarball download hang

Certain corporate firewalls inspect Kubernetes source tar archive
downloads when downloading from mirror.starlingx.cengn.ca with plain
HTTP, which appears to cause wget to encounter its default 15-minute
read time-out due to a stalled download. While the version of wget in
the Debian-based build container does recover successfully from the
time-out, the 15-minute-long time-out is still undesirable.

This commit resolves the same issue resolved by commit ac49ff342c71
("use curl + avoid partial downloads") in the StarlingX tools
repository, the code review for which is at:
  https://review.opendev.org/c/starlingx/tools/+/817049

The change identifier for that commit is:
  Iaa89009ce23efe5b73ecb8163556ce6db932028b

The aforementioned commit was CentOS-based StarlingX, whereas this
commit is for Debian-based StarlingX.

Here are the logs (with additional line-breaks) from build-pkgs'
debrepack module depicting this issue. Note the 15 minute jump from
19:27:21 to 19:42:29, indicating that wget encounters a read time-out.

2022-08-29 19:27:21,361 - debrepack - INFO: \
  === Debian Package Name: kubernetes-1.21.8
2022-08-29 19:27:21,362 - debrepack - INFO: \
  === Package Version: 1.21.8
2022-08-29 19:27:21,397 - debrepack - INFO: \
  Download http://mirror.starlingx.cengn.ca:80/\
    mirror/debian/github.com/kubernetes/kubernetes/\
    archive/refs/tags/v1.21.8.tar.gz to kubernetes-1.21.8.tar.gz
2022-08-29 19:27:21,398 - debrepack - INFO: \
  [ Run - "wget -t 5 --wait=15 \
    http://mirror.starlingx.cengn.ca:80/\
    mirror/debian/github.com/kubernetes/\
    kubernetes/archive/refs/tags/v1.21.8.tar.gz \
    -O kubernetes-1.21.8.tar.gz" ]
2022-08-29 19:42:29,449 - debrepack - INFO: \
  [ Run - "sha256sum kubernetes-1.21.8.tar.gz |cut -d" " -f1" ]
2022-08-29 19:42:29,732 - debrepack - DEBUG: \
  b585d37fb145de9b91cc934669e64ffd0743f40298a2de970509ac182c70a67a

One option to resolve this issue would be to use wget's --read-timeout
option and set the 15-minute time-out to a smaller value such as 5
seconds. This commit opts to use curl instead to avoid the time-out
altogether; curl does not appear to exhibit the same issue.  This is
also the approach taken by the aforementioned commit in the StarlingX
tools repository.

Verification

- The following command line:

    stx shell -c "downloader -c -b -s && build-pkgs -c -a"

  (which forces a fresh download of all source and binary archives) does
  not exhibit any issues, including the Kubernetes tar archive download
  time-out, and the following build-pkgs command to build all packages
  from scratch completes successfully as well.

Closes-Bug: 1988349
Change-Id: I864877af24a38851ac8972386a03c4a692e3b6a4
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
This commit is contained in:
M. Vefa Bicakci 2022-08-29 21:47:51 +00:00
parent d7c5e1c8ba
commit 3ad5c3096a
1 changed files with 3 additions and 1 deletions

View File

@ -190,7 +190,9 @@ def download(url, savepath, logger):
logger.info(f"Download {url} to {savepath}")
# Need to avoid using the shell as the URL may include '&' characters.
run_shell_cmd(["wget", "-t", "5", "--wait=15", url, "-O", savepath], logger)
run_shell_cmd(["curl", "--fail", "--location", "--connect-timeout", "15",
"--speed-time", "15", "--speed-limit", "1", "--retry", "5",
"-o", savepath, url], logger)
return True