From 3e9dee79a881b00d4e5d3e7e08e19a7407bd612b Mon Sep 17 00:00:00 2001 From: Jordan Barrett Date: Mon, 24 Oct 2022 13:36:26 +1100 Subject: [PATCH] Add max attempts to package manager loop --- config/global_constants.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/global_constants.go b/config/global_constants.go index b26e4d9..f4603d5 100644 --- a/config/global_constants.go +++ b/config/global_constants.go @@ -7,17 +7,19 @@ package config const ( // PackageManagerLoopFunction is a bash function that executes its arguments // in a loop with a delay until either the command either returns - // with an exit code other than 100. + // with an exit code other than 100. It times out after 5 failed attempts. PackageManagerLoopFunction = ` function package_manager_loop { + local attempts=0 local rc= while true; do + attempts=$((attempts+1)) if ($*); then return 0 else rc=$? fi - if [ $rc -eq 100 ]; then + if [ $attempts -lt 5 -a $rc -eq 100 ]; then sleep 10s continue fi