Skip to content

Commit 0b1b0f8

Browse files
pengzhoumlPeng Zhou
andauthored
Kubernetes 1.1.2 Bug Fix (#237)
* MLE-14200 update error message * MLE-14114: Fix bug when upgrade with TLS turned on * update script comfigmap to use marklogic.fullname * MLE-14114 Fix bug with Group config for upgrade * fix for PR --------- Co-authored-by: Peng Zhou <[email protected]>
1 parent 001b7a5 commit 0b1b0f8

File tree

3 files changed

+37
-35
lines changed

3 files changed

+37
-35
lines changed

charts/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ oldFullname is the name used before 1.1.x release
6060
{{- $chartVersionString := $chartVersionWithDot | replace "." "" }}
6161
{{- $chartVersionDigit := int $chartVersionString }}
6262
{{- if lt $chartVersionDigit 110 -}}
63-
{{- $errorMessage := printf "New hostnames has been introduced since version 1.1.0. You are upgrading from version %s to version %s. To make the upgrade successful, please set the following configuration in values file to keep using the legacy hostname: \n\nuseLegacyHostnames: true\n" $chartVersionWithDot .Chart.Version }}
63+
{{- $errorMessage := printf "A new algorithm for generating hostnames was introduced in version 1.1.0. When upgrading from version %s to version %s, the \"useLegacyHostnames\" setting must be set to true to prevent the StatefulSet from being recreated. Please add the following to the values file and attempt the upgrade again: \n\nuseLegacyHostnames: true\n" $chartVersionWithDot .Chart.Version }}
6464
{{- fail $errorMessage }}
6565
{{- end }}
6666
{{- end }}

charts/templates/configmap-scripts.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: ConfigMap
33
metadata:
4-
name: {{ .Release.Name }}-scripts
4+
name: {{ include "marklogic.fullname" . }}-scripts
55
data:
66
liveness-probe.sh: |
77
#!/bin/bash

charts/templates/statefulset.yaml

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -316,42 +316,44 @@ spec:
316316
# Begin Group Configuration
317317
if [[ $POD_NAME == *-0 ]] && [[ $MARKLOGIC_CLUSTER_TYPE == "bootstrap" ]]; then
318318
[ -f /var/opt/MarkLogic/group_cfg ] && current_group_cfg=$(cat /var/opt/MarkLogic/group_cfg)
319-
if [ "${MARKLOGIC_GROUP}:${XDQP_SSL_ENABLED}:${MARKLOGIC_JOIN_TLS_ENABLED}" = "${current_group_cfg}" ] ||
320-
[ "${MARKLOGIC_GROUP}:${XDQP_SSL_ENABLED}" = "${current_group_cfg}" ]; then
321-
log "Info: [poststart] Group config has not changed, poststart hook complete"
322-
exit 0
319+
colon_count=$(echo "$current_group_cfg" | awk -F':' '{print NF-1}')
320+
if [ "$colon_count" -eq 2 ]; then
321+
current_group_cfg="${current_group_cfg%:*}"
323322
fi
323+
if [ "${MARKLOGIC_GROUP}:${XDQP_SSL_ENABLED}" = "${current_group_cfg}" ]; then
324+
log "Info: [poststart] Group config has not changed, skip group configuration"
325+
else
326+
log "Info: [poststart] Begin group configuration."
327+
while [ ! -f /var/opt/MarkLogic/ready ]; do
328+
log "[poststart] waiting for MarkLogic server to be ready"
329+
sleep 5s
330+
done
324331
325-
log "Info: [poststart] Begin group configuration."
326-
while [ ! -f /var/opt/MarkLogic/ready ]; do
327-
log "[poststart] waiting for MarkLogic server to be ready"
328-
sleep 5s
329-
done
330-
331-
GROUP_CFG_TEMPLATE='{"group-name":"%s", "xdqp-ssl-enabled":"%s"}'
332-
GROUP_CFG=$(printf "$GROUP_CFG_TEMPLATE" "$MARKLOGIC_GROUP" "$XDQP_SSL_ENABLED")
332+
GROUP_CFG_TEMPLATE='{"group-name":"%s", "xdqp-ssl-enabled":"%s"}'
333+
GROUP_CFG=$(printf "$GROUP_CFG_TEMPLATE" "$MARKLOGIC_GROUP" "$XDQP_SSL_ENABLED")
333334
334-
log "Info: [poststart] Updating group configuration: ${GROUP_CFG}"
335-
GROUP_RESP_CODE=`curl --retry 5 --retry-max-time 60 -o /tmp/restart_payload.xml -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}`
336-
337-
# check whether MarkLogic has restarted
338-
if [[ ${GROUP_RESP_CODE} -eq 202 ]] || [[ ${GROUP_RESP_CODE} -eq 204 ]]; then
339-
log "Info: [poststart] Successfully configured properties for $MARKLOGIC_GROUP group on the MarkLogic cluster."
340-
TIMESTAMP=$(< /tmp/restart_payload.xml grep "last-startup" | sed 's%^.*<last-startup.*>\(.*\)</last-startup>.*$%\1%')
341-
rm -f /tmp/restart_payload.xml
342-
if [[ -n ${TIMESTAMP} ]]; then
343-
restart_check ${TIMESTAMP}
344-
fi
345-
if [[ $MARKLOGIC_IMAGE_TYPE == "rootless" ]]; then
346-
sh -c 'echo -n '"${MARKLOGIC_GROUP}:${XDQP_SSL_ENABLED}:${MARKLOGIC_JOIN_TLS_ENABLED}"' > /var/opt/MarkLogic/group_cfg'
335+
log "Info: [poststart] Updating group configuration: ${GROUP_CFG}"
336+
GROUP_RESP_CODE=`curl --retry 5 --retry-max-time 60 -o /tmp/restart_payload.xml -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}`
337+
338+
# check whether MarkLogic has restarted
339+
if [[ ${GROUP_RESP_CODE} -eq 202 ]] || [[ ${GROUP_RESP_CODE} -eq 204 ]]; then
340+
log "Info: [poststart] Successfully configured properties for $MARKLOGIC_GROUP group on the MarkLogic cluster."
341+
TIMESTAMP=$(< /tmp/restart_payload.xml grep "last-startup" | sed 's%^.*<last-startup.*>\(.*\)</last-startup>.*$%\1%')
342+
rm -f /tmp/restart_payload.xml
343+
if [[ -n ${TIMESTAMP} ]]; then
344+
restart_check ${TIMESTAMP}
345+
fi
346+
if [[ $MARKLOGIC_IMAGE_TYPE == "rootless" ]]; then
347+
sh -c 'echo -n '"${MARKLOGIC_GROUP}:${XDQP_SSL_ENABLED}"' > /var/opt/MarkLogic/group_cfg'
348+
else
349+
sudo sh -c 'echo -n '"${MARKLOGIC_GROUP}:${XDQP_SSL_ENABLED}"' > /var/opt/MarkLogic/group_cfg'
350+
fi
351+
log "Info: [poststart] ${GROUP_CFG} saved"
347352
else
348-
sudo sh -c 'echo -n '"${MARKLOGIC_GROUP}:${XDQP_SSL_ENABLED}:${MARKLOGIC_JOIN_TLS_ENABLED}"' > /var/opt/MarkLogic/group_cfg'
353+
log "Error: [poststart] Failed to configure properties for $MARKLOGIC_GROUP group.
354+
log "Error: [poststart] Expected response code 202 or 204, got "${GROUP_RESP_CODE}"
355+
exit 1
349356
fi
350-
log "Info: [poststart] ${GROUP_CFG} saved"
351-
else
352-
log "Error: [poststart] Failed to configure properties for $MARKLOGIC_GROUP group.
353-
log "Error: [poststart] Expected response code 202 or 204, got "${GROUP_RESP_CODE}"
354-
exit 1
355357
fi
356358
else
357359
log "Info: [poststart] This is not bootstrap host. Skipping group configuration."
@@ -362,7 +364,7 @@ spec:
362364
https_error_message="You have attempted to access an HTTPS server using HTTP."
363365
resp=$(curl -s http://localhost:8001)
364366
if [[ "$resp" == *"$https_error_message"* ]]; then
365-
log "Info: [poststart] MarkLogic server has already configured HTTPS"
367+
log "Info: [poststart] MarkLogic server has already configured HTTPS"
366368
exit 0
367369
else
368370
log "Info: [poststart] MARKLOGIC_JOIN_TLS_ENABLED is set to true, configuring SSL"
@@ -662,7 +664,7 @@ spec:
662664
secretName: {{ include "marklogic.authSecretNameToMount" . }}
663665
- name: scripts
664666
configMap:
665-
name: {{ .Release.Name }}-scripts
667+
name: {{ include "marklogic.fullname" . }}-scripts
666668
defaultMode: 0755
667669
{{- if .Values.logCollection.enabled }}
668670
- name: {{ include "marklogic.fullname" . }}-fb-config-map

0 commit comments

Comments
 (0)