diff options
author | William A. Kennington III <wak@google.com> | 2022-05-25 04:53:52 +0300 |
---|---|---|
committer | William A. Kennington III <wak@google.com> | 2022-06-11 21:52:17 +0300 |
commit | 3cfbd1542958b656f38389758579e0640d6462cb (patch) | |
tree | e2f223f5674f13ada28b3665b38a05e858c75e68 | |
parent | 1fbee91ecebd2d0bcc6f0ca4ce9431ae77ff265a (diff) | |
download | openbmc-3cfbd1542958b656f38389758579e0640d6462cb.tar.xz |
meta-google: gbmc-update: Fix fetch error logic
We want to produce a meaningful error if we time out unpacking the
download tarball.
Change-Id: I4710e70925d8c4be93430739f8a2f7e4ece47ebf
Signed-off-by: William A. Kennington III <wak@google.com>
-rw-r--r-- | meta-google/recipes-phosphor/flash/gbmc-update/75-gbmc-upgrade.sh | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/meta-google/recipes-phosphor/flash/gbmc-update/75-gbmc-upgrade.sh b/meta-google/recipes-phosphor/flash/gbmc-update/75-gbmc-upgrade.sh index 9d55eeec53..9fe51cce2b 100644 --- a/meta-google/recipes-phosphor/flash/gbmc-update/75-gbmc-upgrade.sh +++ b/meta-google/recipes-phosphor/flash/gbmc-update/75-gbmc-upgrade.sh @@ -49,13 +49,28 @@ gbmc_upgrade_fetch() ( local max_mb=$((2*64 + 2)) ulimit -f $((max_mb * 1024 * 1024 / 512)) || return timeout=$((SECONDS + 300)) - while (( SECONDS < timeout )); do - local st=(0) + stime=5 + while true; do + local st=() curl -LSsk --max-time $((timeout - SECONDS)) "$bootfile_url" | - tar -xC "$tmpdir" "firmware-gbmc/$machine" || st=("${PIPESTATUS[@]}") - (( st[0] != 0 )) || break + tar -xC "$tmpdir" "firmware-gbmc/$machine" \ + && st=("${PIPESTATUS[@]}") || st=("${PIPESTATUS[@]}") + # Curl failures should continue + if (( st[0] == 0 )); then + # Tar failures when curl succeeds are hard errors to start over. + if (( st[1] != 0 )); then + echo 'Unpacking failed' >&2 + return 1 + fi + # Success should continue without retry + break + fi + if (( SECONDS + stime >= timeout )); then + echo 'Timed out fetching image' >&2 + return 1 + fi (shopt -s nullglob dotglob; rm -rf -- "${tmpdir:?}"/*) - sleep 5 + sleep $stime done local sig |