Fix shellcheck lint errors in test/kubemark/common/util.sh

pull/564/head
Bob Killen 2019-02-04 17:28:08 -06:00
parent 9a4f4878f5
commit 5f4b919887
No known key found for this signature in database
GPG Key ID: 03FB8A8615239E6D
2 changed files with 7 additions and 3 deletions

View File

@ -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

View File

@ -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
}