From 074ca55a1ca33169997487283712b8b9737f720f Mon Sep 17 00:00:00 2001 From: Fred Park Date: Fri, 1 Nov 2019 15:00:58 +0000 Subject: [PATCH] Extend retries on package manager contention --- scripts/shipyard_nodeprep.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/shipyard_nodeprep.sh b/scripts/shipyard_nodeprep.sh index 85c5c9d..21219d8 100755 --- a/scripts/shipyard_nodeprep.sh +++ b/scripts/shipyard_nodeprep.sh @@ -494,6 +494,13 @@ install_packages() { if [ $retries -eq 0 ]; then log ERROR "Could not install packages ($PACKAGER): $*" exit 1 + else + # extend retries (by sleeping longer in-between) in the case of packager lock contention + if [ "$PACKAGER" == "apt" ]; then + if lsof /var/lib/dpkg/lock-frontend; then + sleep 2 + fi + fi fi sleep 1 done @@ -517,8 +524,15 @@ install_local_packages() { fi retries=$((retries-1)) if [ $retries -eq 0 ]; then - log ERROR "Could not install local packages: $*" + log ERROR "Could not install local packages ($PACKAGER): $*" exit 1 + else + # extend retries (by sleeping longer in-between) in the case of packager lock contention + if [ "$PACKAGER" == "apt" ]; then + if lsof /var/lib/dpkg/lock-frontend; then + sleep 2 + fi + fi fi sleep 1 done