Skip to content

Commit c8398c9

Browse files
sumanthravipatiSumanth Ravipati
andauthored
CLD-479: Adding ML Host changes commit
* CLD-479: Adding ML Host changes commit * CLD-479: Updated the Shut Down retry logic * CLD-479: Improve logging message format * CLD-479: Improved logging logic * CLD-479: Updated the logging logic to capture the correct timestamp Co-authored-by: Sumanth Ravipati <[email protected]>
1 parent e492fc2 commit c8398c9

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

charts/templates/statefulset.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ spec:
2020
{{- with .Values.affinity }}
2121
affinity: {{- toYaml . | nindent 8}}
2222
{{- end }}
23+
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod }}
2324
containers:
2425
- name: marklogic-server
2526
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
@@ -60,6 +61,53 @@ spec:
6061
{{- if .Values.extraContainerPorts }}
6162
{{- toYaml .Values.extraContainerPorts | nindent 12 }}
6263
{{- end }}
64+
lifecycle:
65+
preStop:
66+
exec:
67+
command:
68+
- bash
69+
- '-c'
70+
- |
71+
log () {
72+
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
73+
echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
74+
}
75+
76+
pid=$(ps aux | grep -i '/bin/bas[h] /usr' | awk {'print $2'})
77+
log "Info: [prestop] Prestop Hook Execution"
78+
79+
my_host=$(hostname -f)
80+
81+
log "Info: [prestop] MarkLogic Pod Hostname: "$my_host
82+
83+
for ((i = 0; i < 5; i = i + 1)); do
84+
res_code=$(curl --anyauth --user $MARKLOGIC_ADMIN_USERNAME:$MARKLOGIC_ADMIN_PASSWORD \
85+
-o /dev/null -m 10 -s -w %{http_code} \
86+
-i -X POST --data "state=shutdown&failover=true" \
87+
-H "Content-type: application/x-www-form-urlencoded" \
88+
http://localhost:8002/manage/v2/hosts/$my_host?format=json)
89+
90+
if [[ ${res_code} -eq 202 ]]; then
91+
log "Info: [prestop] Host shut down response code: "$res_code
92+
93+
while (true)
94+
do
95+
ml_status=$(service MarkLogic status)
96+
log "Info: [prestop] MarkLogic Status: "$ml_status
97+
if [[ "$ml_status" =~ "running" ]]; then
98+
sleep 5s
99+
continue
100+
else
101+
break
102+
fi
103+
done
104+
break
105+
else
106+
log "ERROR: [prestop] Retry Attempt: "$i
107+
log "ERROR: [prestop] Host shut down expected response code 202, got "$res_code
108+
sleep 10s
109+
fi
110+
done
63111
{{- if .Values.livenessProbe.enabled }}
64112
livenessProbe:
65113
httpGet:

charts/values.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
# Number of Marklogic nodes
44
replicaCount: 1
55

6+
# Termination Grace Period
7+
terminationGracePeriod: 120
8+
69
# Marklogic image parameters
710
image:
811
repository: marklogicdb/marklogic-db
9-
tag: 10.0-9.1-centos-1.0.0-ea4
12+
tag: 10.0-9.2-centos-1.0.0-ea4
1013
pullPolicy: IfNotPresent
1114

1215
# Configure the imagePullSecret to pull the image from private repository that requires credential

0 commit comments

Comments
 (0)