From bc8e200919f31936fd6e875916d8caccefb91ff6 Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Sun, 10 Jan 2021 02:34:46 -0500 Subject: [PATCH] Continued retry implementation for salt-key acceptance; improve timestamp coverage in setup --- salt/common/tools/sbin/so-common | 13 +++++++++++-- setup/so-functions | 4 +++- setup/so-setup | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/salt/common/tools/sbin/so-common b/salt/common/tools/sbin/so-common index caa19cd37..0c18c4482 100755 --- a/salt/common/tools/sbin/so-common +++ b/salt/common/tools/sbin/so-common @@ -145,12 +145,21 @@ retry() { maxAttempts=$1 sleepDelay=$2 cmd=$3 + expectedOutput=$4 attempt=0 while [[ $attempt -lt $maxAttempts ]]; do attempt=$((attempt+1)) - logCmd "$cmd" + info "Executing command with retry support: $cmd" + output=$($cmd) + info "Results: $output" exitcode=$? - if [[ $exitcode -eq 0 ]]; then + if [ -n "$expectedOutput" ]; then + if [[ "$output" =~ "$expectedOutput" ]]; then + return $exitCode + else + info "Expected '$expectedOutput' but got '$output'" + fi + elif [[ $exitcode -eq 0 ]]; then return $exitCode fi info "Command failed with exit code $exitcode; will retry in $sleepDelay seconds ($attempt / $maxAttempts)..." diff --git a/setup/so-functions b/setup/so-functions index b2b7b688c..e9de76233 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -1970,9 +1970,11 @@ set_progress_str() { echo -e "$percentage_str" + info "Progressing ($percentage%): $progress_bar_text" + printf '%s\n' \ '----'\ - info "$percentage% - ${progress_bar_text^^}"\ + "$percentage% - ${progress_bar_text^^}"\ "----" >> "$setup_log" 2>&1 } diff --git a/setup/so-setup b/setup/so-setup index 28f0bc0bb..e62dc434f 100755 --- a/setup/so-setup +++ b/setup/so-setup @@ -637,12 +637,12 @@ set_redirect >> $setup_log 2>&1 if [[ $is_minion ]]; then set_progress_str 20 'Accepting Salt key on manager' - retry 20 10 accept_salt_key_remote + retry 20 10 accept_salt_key_remote "going to be accepted" fi if [[ $is_manager || $is_import || $is_helix ]]; then set_progress_str 20 'Accepting Salt key' - retry 20 10 "salt-key -ya $MINION_ID" + retry 20 10 "salt-key -ya $MINION_ID" "going to be accepted" fi set_progress_str 21 'Copying minion pillars to manager'