[Fix] Add retry to check_then_set

Retry logic was added in the check_then_set function to avoid edge case
scenarios where the rack controller is not synced yet.

Change-Id: I33fe7aabf32b872d67c31616ee6074d262aece4a
This commit is contained in:
anthony.bellino 2019-05-30 21:11:02 +00:00
parent ce4a4404d7
commit edf2c549ad
1 changed files with 21 additions and 11 deletions

View File

@ -75,18 +75,28 @@ function check_then_set {
option=$1
value=$2
cur_val=$(maas ${ADMIN_USERNAME} maas get-config name=${option} | tail -1 | tr -d '"')
desired_val=$(echo ${value} | tr -d '"')
while [[ ${JOB_TIMEOUT} -gt 0 ]]
do
cur_val=$(maas ${ADMIN_USERNAME} maas get-config name=${option} | tail -1 | tr -d '"')
desired_val=$(echo ${value} | tr -d '"')
if [[ $cur_val != $desired_val ]]
then
echo "Setting MAAS option ${option} to ${desired_val}"
maas ${ADMIN_USERNAME} maas set-config name=${option} value=${desired_val}
return $?
else
echo "MAAS option ${option} already set to ${cur_val}"
return 0
fi
if [[ $cur_val != $desired_val ]]
then
echo "Setting MAAS option ${option} to ${desired_val}"
maas ${ADMIN_USERNAME} maas set-config name=${option} value=${desired_val}
if [[ $? -gt 0 ]]
then
let JOB_TIMEOUT-=${RETRY_TIMER}
sleep ${RETRY_TIMER}
else
return $?
fi
else
echo "MAAS option ${option} already set to ${cur_val}"
return 0
fi
done
return 1
}
function configure_proxy {