Improve retry_cmd function to handle set -e

In run_tests.sh we use 'set -e' which makes
script fail as soon as error hit but we don't
want to fail in case of retries, this patch fixes it.

Change-Id: Ia33ff3dbb88317171143a43e5b1c674038187254
This commit is contained in:
yatinkarel 2021-02-05 14:01:00 +05:30
parent eaab90a97a
commit ec57a35931

View File

@ -13,11 +13,17 @@ retry_cmd() {
local ret_code=1
until [[ ${ret_code} -eq 0 || ${retry_count} -gt ${total_tries} ]]; do
echo Retry count:-${retry_count}, Command:-$cmd
set +e
$cmd
ret_code=$?
set -e
((retry_count++))
sleep ${delay}
done
if [ ${ret_code} -ne 0 ]; then
echo Failed even after ${total_tries} retries, Exiting
exit ${ret_code}
fi
}
# Install external Puppet modules with r10k