From 5f4b919887787daff38ec3d66ff60fa74388d358 Mon Sep 17 00:00:00 2001 From: Bob Killen Date: Mon, 4 Feb 2019 17:28:08 -0600 Subject: [PATCH] Fix shellcheck lint errors in test/kubemark/common/util.sh --- hack/.shellcheck_failures | 1 - test/kubemark/common/util.sh | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hack/.shellcheck_failures b/hack/.shellcheck_failures index bb21510204..77b53dd1d7 100644 --- a/hack/.shellcheck_failures +++ b/hack/.shellcheck_failures @@ -145,7 +145,6 @@ ./test/images/volume/rbd/create_block.sh ./test/images/volume/rbd/mon.sh ./test/images/volume/rbd/osd.sh -./test/kubemark/common/util.sh ./test/kubemark/gce/util.sh ./test/kubemark/iks/shutdown.sh ./test/kubemark/iks/startup.sh diff --git a/test/kubemark/common/util.sh b/test/kubemark/common/util.sh index 171397bcbe..05cdba4c77 100644 --- a/test/kubemark/common/util.sh +++ b/test/kubemark/common/util.sh @@ -17,7 +17,7 @@ # Running cmd $RETRIES times in case of failures. function run-cmd-with-retries { RETRIES="${RETRIES:-3}" - for attempt in $(seq 1 ${RETRIES}); do + for attempt in $(seq 1 "${RETRIES}"); do local ret_val=0 exec 5>&1 # Duplicate &1 to &5 for use below. # We don't use 'local' to declare result as then ret_val always gets value 0. @@ -26,19 +26,24 @@ function run-cmd-with-retries { if [[ "${ret_val:-0}" -ne "0" ]]; then if [[ $(echo "${result}" | grep -c "already exists") -gt 0 ]]; then if [[ "${attempt}" == 1 ]]; then + # shellcheck disable=SC2154 # Color defined in sourced script echo -e "${color_red}Failed to $1 $2 ${3:-} as the resource hasn't been deleted from a previous run.${color_norm}" >& 2 exit 1 fi + # shellcheck disable=SC2154 # Color defined in sourced script echo -e "${color_yellow}Succeeded to $1 $2 ${3:-} in the previous attempt, but status response wasn't received.${color_norm}" return 0 fi + # shellcheck disable=SC2154 # Color defined in sourced script echo -e "${color_yellow}Attempt $attempt failed to $1 $2 ${3:-}. Retrying.${color_norm}" >& 2 - sleep $(($attempt * 5)) + sleep $((attempt * 5)) else + # shellcheck disable=SC2154 # Color defined in sourced script echo -e "${color_green}Succeeded to $1 $2 ${3:-}.${color_norm}" return 0 fi done + # shellcheck disable=SC2154 # Color defined in sourced script echo -e "${color_red}Failed to $1 $2 ${3:-}.${color_norm}" >& 2 exit 1 }