Skip to content

Commit 19a1924

Browse files
Barkha Choithanibarkhachoithani
authored andcommitted
Change sleep statements to check for required conditions in the k8s scripts
1 parent 444f874 commit 19a1924

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

charts/templates/statefulset.yaml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,28 @@ spec:
174174
log "[poststart] wait for marklogic server to be ready"
175175
sleep 5s
176176
done
177-
sleep 10s
177+
178+
# Fetch timestamp before updating group config
179+
TIMESTAMP=`curl --anyauth http://${MARKLOGIC_BOOTSTRAP_HOST}:8001/admin/v1/timestamp --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}`
180+
178181
GROUP_CFG_TEMPLATE='{"group-name":"%s", "xdqp-ssl-enabled":"%s"}'
179182
GROUP_CFG=$(printf "$GROUP_CFG_TEMPLATE" "$MARKLOGIC_GROUP" "$XDQP_SSL_ENABLED")
180183
log "Info: [poststart] Updating group configuration: ${GROUP_CFG}"
181-
curl --anyauth -m 20 -X PUT -H "Content-type: application/json" -d "${GROUP_CFG}" http://${MARKLOGIC_BOOTSTRAP_HOST}:8002/manage/v2/groups/Default/properties --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}
182-
sleep 2s
184+
GROUP_RESP_CODE=`curl --retry 5 --retry-max-time 60 -o /dev/null -w "%{http_code}" --anyauth -m 20 -s -X PUT -H "Content-type: application/json" -d "${GROUP_CFG}" http://${MARKLOGIC_BOOTSTRAP_HOST}:8002/manage/v2/groups/Default/properties --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}`
185+
186+
# check if MarkLogic has restarted
187+
if [[ ${GROUP_RESP_CODE} -eq 202 ]]; then
188+
log "Info: [poststart] Waiting for MarkLogic to restart."
189+
LAST_START=`curl --anyauth http://${MARKLOGIC_BOOTSTRAP_HOST}:8001/admin/v1/timestamp --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}`
190+
for i in $(seq 1 5); do
191+
if [ ${TIMESTAMP} == ${LAST_START} ] || [ -z ${LAST_START} ]; then
192+
sleep 10
193+
LAST_START=`curl --anyauth http://${MARKLOGIC_BOOTSTRAP_HOST}:8001/admin/v1/timestamp --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}`
194+
else
195+
log "Info: [poststart] MarkLogic has restarted."
196+
fi
197+
done
198+
fi
183199
fi
184200
log "Info: [poststart] Poststart Hook Execution Completed"
185201
{{- end }}

0 commit comments

Comments
 (0)