From edf2c549ad7a1fbe2c0251bda0edf2f2d0772413 Mon Sep 17 00:00:00 2001 From: "anthony.bellino" Date: Thu, 30 May 2019 21:11:02 +0000 Subject: [PATCH] [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 --- .../bin/_import-boot-resources.sh.tpl | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/charts/maas/templates/bin/_import-boot-resources.sh.tpl b/charts/maas/templates/bin/_import-boot-resources.sh.tpl index 98ccf5f..d08c2ee 100644 --- a/charts/maas/templates/bin/_import-boot-resources.sh.tpl +++ b/charts/maas/templates/bin/_import-boot-resources.sh.tpl @@ -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 {