Skip to content

Commit dfde5bf

Browse files
author
Peng Zhou
committed
MLE-21148: Add retry for group config
1 parent d8d9664 commit dfde5bf

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

charts/templates/configmap-scripts.yaml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ metadata:
99
data:
1010
copy-certs.sh: |
1111
#!/bin/bash
12-
MARKLOGIC_ADMIN_USERNAME="$(< /run/secrets/ml-secrets/username)"
13-
MARKLOGIC_ADMIN_PASSWORD="$(< /run/secrets/ml-secrets/username)"
1412
log () {
1513
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
1614
echo "${TIMESTAMP} $@"
@@ -176,6 +174,22 @@ data:
176174
echo $message >> /tmp/script.log
177175
}
178176
177+
retry() {
178+
local retries=$1
179+
shift
180+
local count=0
181+
until "$@"; do
182+
exit_code=$?
183+
count=$((count + 1))
184+
if [ $count -ge $retries ]; then
185+
echo "Command failed after $retries attempts."
186+
return $exit_code
187+
fi
188+
echo "Attempt $count failed. Retrying..."
189+
sleep 5
190+
done
191+
}
192+
179193
###############################################################
180194
# Function to get the current host protocol
181195
# $1: The host name
@@ -559,9 +573,11 @@ data:
559573
info "group \"${current_group}\" updated and a restart of all hosts in the group was triggered"
560574
else
561575
info "unexpected response when updating group \"${current_group}\": ${response_code}"
576+
return 1
562577
fi
563578
else
564579
info "failed to get current group, response code: ${response_code}"
580+
return 1
565581
fi
566582
567583
if [[ "$MARKLOGIC_CLUSTER_TYPE" == "non-bootstrap" ]]; then
@@ -584,7 +600,7 @@ data:
584600
else
585601
info "not bootstrap host. Skip group configuration"
586602
fi
587-
603+
return 0
588604
}
589605
590606
function configure_tls {
@@ -813,10 +829,10 @@ data:
813829
if [[ "${MARKLOGIC_CLUSTER_TYPE}" == "bootstrap" ]]; then
814830
log "Info: bootstrap host is ready"
815831
init_security_db
816-
configure_group
832+
retry 5 configure_group
817833
else
818834
log "Info: bootstrap host is ready"
819-
configure_group
835+
retry 5 configure_group
820836
join_cluster $HOST_FQDN
821837
fi
822838
configure_path_based_routing

0 commit comments

Comments
 (0)