@@ -33,27 +33,36 @@ spec:
33
33
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
34
34
echo "${TIMESTAMP} $@"
35
35
}
36
- log "Info: [initContainer] Begin init container configure-group execution"
36
+ log "Info: [initContainer] Begin configure-group execution"
37
37
if [[ $POD_NAME != *-0 ]]; then
38
38
log "Info: [initContainer] Skipping creation of group $MARKLOGIC_GROUP as $POD_NAME is not the first node in the group."
39
- else
40
- HOST_RESP_CODE=`curl --anyauth -m 20 -s -o /dev/null -w "%{http_code}" -X GET http://${MARKLOGIC_BOOTSTRAP_HOST}:8002/manage/v2/hosts --anyauth --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}`
41
- if [[ ${HOST_RESP_CODE} -ne 200 ]]; then
42
- log "Error: [initContainer] Bootstrap host $MARKLOGIC_BOOTSTRAP_HOST not found."
43
- else
44
- GROUP_CFG_TEMPLATE='{"group-name":"%s"}'
45
- GROUP_CFG=$(printf "$GROUP_CFG_TEMPLATE" "$MARKLOGIC_GROUP")
46
- GROUP_RESP_CODE=`curl --anyauth -m 20 -s -o /dev/null -w "%{http_code}" -X GET http://${MARKLOGIC_BOOTSTRAP_HOST}:8002/manage/v2/groups/${MARKLOGIC_GROUP} --anyauth --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}`
47
-
48
- if [[ ${GROUP_RESP_CODE} -eq 200 ]]; then
49
- log "Info: [initContainer] Skipping creation of group $MARKLOGIC_GROUP as it already exists on the MarkLogic cluster."
50
- else
51
- log "Info: [initContainer] Group $MARKLOGIC_GROUP does not exist, creating $MARKLOGIC_GROUP on the MarkLogic cluster."
52
- curl --anyauth --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD} -m 20 -s -X POST -d "${GROUP_CFG}" -H "Content-type: application/json" http://${MARKLOGIC_BOOTSTRAP_HOST}:8002/manage/v2/groups
53
- fi
54
- fi
39
+ exit 0
40
+ fi
41
+ HOST_RESP_CODE=`curl --anyauth -m 20 -s -o /dev/null -w "%{http_code}" -X GET http://${MARKLOGIC_BOOTSTRAP_HOST}:8002/manage/v2/hosts --anyauth --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}`
42
+ if [[ ${HOST_RESP_CODE} -ne 200 ]]; then
43
+ log "Error: [initContainer] Bootstrap host $MARKLOGIC_BOOTSTRAP_HOST not found, exiting Init container."
44
+ exit 1
55
45
fi
56
- log "Info: [initContainer] Init container execution completed"
46
+ GROUP_CFG_TEMPLATE='{"group-name":"%s"}'
47
+ GROUP_CFG=$(printf "$GROUP_CFG_TEMPLATE" "$MARKLOGIC_GROUP")
48
+ GROUP_RESP_CODE=`curl --anyauth -m 20 -s -o /dev/null -w "%{http_code}" -X GET http://${MARKLOGIC_BOOTSTRAP_HOST}:8002/manage/v2/groups/${MARKLOGIC_GROUP} --anyauth --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}`
49
+ if [[ ${GROUP_RESP_CODE} -eq 200 ]]; then
50
+ log "Info: [initContainer] Skipping creation of group $MARKLOGIC_GROUP as it already exists on the MarkLogic cluster."
51
+ exit 0
52
+ fi
53
+ log "Info: [initContainer] Group $MARKLOGIC_GROUP does not exist, configuring group $MARKLOGIC_GROUP on the MarkLogic cluster."
54
+ for i in $(seq 1 5); do
55
+ res_code=`curl --anyauth --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD} -m 20 -s -w '%{http_code}' -X POST -d "${GROUP_CFG}" -H "Content-type: application/json" http://${MARKLOGIC_BOOTSTRAP_HOST}:8002/manage/v2/groups`
56
+ if [[ ${res_code} -eq 201 ]]; then
57
+ log "Info: [initContainer] Successfully configured group $MARKLOGIC_GROUP on the MarkLogic cluster."
58
+ break
59
+ else
60
+ log "Info: [initContainer] Configure group $MARKLOGIC_GROUP retry attempt $i "
61
+ log "Info: [initContainer] Expected response code 202, got $res_code"
62
+ sleep 10s
63
+ fi
64
+ [ $i -eq 5 ] && exit 1
65
+ done
57
66
env :
58
67
- name : MARKLOGIC_GROUP
59
68
value : {{ .Values.group.name }}
0 commit comments