From 55527036b4eeff063895b856f6868a00b93e04c8 Mon Sep 17 00:00:00 2001 From: Shyam Jeedigunta Date: Mon, 24 Jul 2017 15:53:41 +0200 Subject: [PATCH] Fix bug in command retrying in kubemark --- test/kubemark/common/util.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/kubemark/common/util.sh b/test/kubemark/common/util.sh index 1f4ccbc0aa5..d3c035776c2 100644 --- a/test/kubemark/common/util.sh +++ b/test/kubemark/common/util.sh @@ -18,10 +18,11 @@ function run-cmd-with-retries { RETRIES="${RETRIES:-3}" 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. # We use tee to output to &5 (redirected to stdout) while also storing it in the variable. - result=$("$@" 2>&1 | tee >(cat - >&5)) || local ret_val="$?" + result=$("$@" 2>&1 | tee >(cat - >&5)) || ret_val="$?" if [[ "${ret_val:-0}" -ne "0" ]]; then if [[ $(echo "${result}" | grep -c "already exists") -gt 0 ]]; then if [[ "${attempt}" == 1 ]]; then