diff --git a/lib/functions/image/loop.sh b/lib/functions/image/loop.sh index 6866657bc..275e007a8 100644 --- a/lib/functions/image/loop.sh +++ b/lib/functions/image/loop.sh @@ -35,8 +35,13 @@ function check_loop_device_internal() { run_host_command_logged ls -la "${device}" run_host_command_logged lsblk run_host_command_logged blkid - display_alert "Device node exists but is 0-sized" "${device}" "debug" - return 1 + # only break on the first 3 iteractions. then give up; let it try to use the device... + if [[ ${RETRY_RUNS} -lt 4 ]]; then + display_alert "Device node exists but is 0-sized; retry ${RETRY_RUNS}" "${device}" "warn" + return 1 + else + display_alert "Device node exists but is 0-sized; proceeding anyway" "${device}" "warn" + fi fi fi diff --git a/lib/functions/logging/runners.sh b/lib/functions/logging/runners.sh index a31881f58..6213c3a74 100644 --- a/lib/functions/logging/runners.sh +++ b/lib/functions/logging/runners.sh @@ -253,12 +253,14 @@ function do_with_retries() { local counter=0 while [[ $counter -lt $retries ]]; do counter=$((counter + 1)) + declare -i RETRY_RUNS=${counter} "$@" && return 0 # execute and return 0 if success; if not, let it loop; if [[ "${silent_retry}" == "yes" ]]; then : # do nothing else display_alert "Command failed, retrying in ${sleep_seconds}s" "$*" "warn" fi + unset RETRY_RUNS sleep ${sleep_seconds} done display_alert "Command failed ${counter} times, giving up" "$*" "warn"