@@ -10,8 +10,6 @@ metadata:
1010data :
1111 copy-certs.sh : |
1212 #!/bin/bash
13- MARKLOGIC_ADMIN_USERNAME="$(< /run/secrets/ml-secrets/username)"
14- MARKLOGIC_ADMIN_PASSWORD="$(< /run/secrets/ml-secrets/username)"
1513 log () {
1614 local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
1715 echo "${TIMESTAMP} $@"
@@ -177,6 +175,25 @@ data:
177175 echo $message >> /tmp/script.log
178176 }
179177
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+
180197 ###############################################################
181198 # Function to get the current host protocol
182199 # $1: The host name
@@ -560,6 +577,7 @@ data:
560577 info "group \"${current_group}\" updated and a restart of all hosts in the group was triggered"
561578 else
562579 info "unexpected response when updating group \"${current_group}\": ${response_code}"
580+ return 1
563581 fi
564582 else
565583 info "failed to get current group, response code: ${response_code}"
@@ -585,7 +603,7 @@ data:
585603 else
586604 info "not bootstrap host. Skip group configuration"
587605 fi
588-
606+ return 0
589607 }
590608
591609 function configure_tls {
@@ -814,10 +832,10 @@ data:
814832 if [[ "${MARKLOGIC_CLUSTER_TYPE}" == "bootstrap" ]]; then
815833 log "Info: bootstrap host is ready"
816834 init_security_db
817- configure_group
835+ retry 5 configure_group
818836 else
819837 log "Info: bootstrap host is ready"
820- configure_group
838+ retry 5 configure_group
821839 join_cluster $HOST_FQDN
822840 fi
823841 configure_path_based_routing
0 commit comments