From ff0a7ccabb8c439b49fa1262608f77393a3eb4c4 Mon Sep 17 00:00:00 2001 From: "Yasin, Siraj (SY495P)" Date: Fri, 6 Dec 2019 16:26:45 +0000 Subject: [PATCH] [apt-retry] - Added logic to retry apt update When there is failure to fetch any of the apt urls, it skips and continues. Due to which apt install fails in next step. So added retry if apt fetch fails before proceeding to apt install. Change-Id: I658024481b1be98d280cb1c9c4c2fb733a0d5697 --- promenade/templates/include/up.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/promenade/templates/include/up.sh b/promenade/templates/include/up.sh index 83e53e2e..5555eb2b 100644 --- a/promenade/templates/include/up.sh +++ b/promenade/templates/include/up.sh @@ -82,15 +82,16 @@ set -x end=$(($(date +%s) + APT_INSTALL_TIMEOUT)) while true; do - if ! apt-get update; then + if ! apt-get update 2>&1 | grep -q '^W: Failed to fetch'; then + break + else now=$(date +%s) if [[ ${now} -gt ${end} ]]; then - log Failed to update apt-cache. + log "Failed to update apt-cache." exit 1 fi + log "re-try apt-get update..." sleep 10 - else - break fi done