From da2408e4ea988090835f15f29cb170873cced045 Mon Sep 17 00:00:00 2001 From: Adam Farley Date: Fri, 1 Dec 2023 15:32:10 +0000 Subject: [PATCH] WIP: Rerun gpg recv-keys command multiple times (#3544) Rerun the recv-keys command 10 times if it fails This allows us to hopefully provide some tolerance against the timeout errors, while at the same time using the same keyserver; fixing the problem while not modifying our risk profile. Signed-off-by: Adam Farley --- sbin/prepareWorkspace.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sbin/prepareWorkspace.sh b/sbin/prepareWorkspace.sh index 5f44dee93..caddef32d 100644 --- a/sbin/prepareWorkspace.sh +++ b/sbin/prepareWorkspace.sh @@ -336,7 +336,18 @@ checkingAndDownloadingAlsa() { # Note: the uptime command below is to aid diagnostics for this issue: # https://github.com/adoptium/temurin-build/issues/3518#issuecomment-1792606345 uptime - gpg --keyserver keyserver.ubuntu.com --keyserver-options timeout=300 --recv-keys "${ALSA_LIB_GPGKEYID}" + # Will retry command below until it passes or we've failed 10 times. + for i in {1..10}; do + if gpg --keyserver keyserver.ubuntu.com --keyserver-options timeout=300 --recv-keys "${ALSA_LIB_GPGKEYID}"; then + echo "gpg command has passed." + break + elif [[ ${i} -lt 10 ]]; then + echo "gpg recv-keys attempt has failed. Retrying after 10 second pause..." + sleep 10s + else + echo "ERROR: gpg recv-keys final attempt has failed. Will not try again." + fi + done echo -e "5\ny\n" | gpg --batch --command-fd 0 --expert --edit-key "${ALSA_LIB_GPGKEYID}" trust; gpg --verify alsa-lib.tar.bz2.sig alsa-lib.tar.bz2 || exit 1