@@ -10,8 +10,6 @@ metadata:
10
10
data :
11
11
copy-certs.sh : |
12
12
#!/bin/bash
13
- MARKLOGIC_ADMIN_USERNAME="$(< /run/secrets/ml-secrets/username)"
14
- MARKLOGIC_ADMIN_PASSWORD="$(< /run/secrets/ml-secrets/username)"
15
13
log () {
16
14
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
17
15
echo "${TIMESTAMP} $@"
@@ -177,6 +175,25 @@ data:
177
175
echo $message >> /tmp/script.log
178
176
}
179
177
178
+ # Function to retry a command based on the return code
179
+ # $1: The number of retries
180
+ # $2: The command to run
181
+ retry() {
182
+ local retries=$1
183
+ shift
184
+ local count=0
185
+ until "$@"; do
186
+ exit_code=$?
187
+ count=$((count + 1))
188
+ if [ $count -ge $retries ]; then
189
+ echo "Command failed after $retries attempts."
190
+ return $exit_code
191
+ fi
192
+ echo "Attempt $count failed. Retrying..."
193
+ sleep 5
194
+ done
195
+ }
196
+
180
197
###############################################################
181
198
# Function to get the current host protocol
182
199
# $1: The host name
@@ -560,6 +577,7 @@ data:
560
577
info "group \"${current_group}\" updated and a restart of all hosts in the group was triggered"
561
578
else
562
579
info "unexpected response when updating group \"${current_group}\": ${response_code}"
580
+ return 1
563
581
fi
564
582
else
565
583
info "failed to get current group, response code: ${response_code}"
@@ -585,7 +603,7 @@ data:
585
603
else
586
604
info "not bootstrap host. Skip group configuration"
587
605
fi
588
-
606
+ return 0
589
607
}
590
608
591
609
function configure_tls {
@@ -814,10 +832,10 @@ data:
814
832
if [[ "${MARKLOGIC_CLUSTER_TYPE}" == "bootstrap" ]]; then
815
833
log "Info: bootstrap host is ready"
816
834
init_security_db
817
- configure_group
835
+ retry 5 configure_group
818
836
else
819
837
log "Info: bootstrap host is ready"
820
- configure_group
838
+ retry 5 configure_group
821
839
join_cluster $HOST_FQDN
822
840
fi
823
841
configure_path_based_routing
0 commit comments