Skip to content

Commit 75b4d16

Browse files
sumanthravipatiSumanth Ravipati
andauthored
CLD-647: PID bugfix in prestop and poststop hook
Co-authored-by: Sumanth Ravipati <[email protected]>
1 parent 1d42286 commit 75b4d16

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

charts/templates/statefulset.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,15 @@ spec:
137137
- bash
138138
- '-c'
139139
- |
140-
pid=$(ps aux | grep -i '/bin/bas[h] /usr' | awk {'print $2'})
140+
pid=$(pgrep start.marklogic)
141141
142142
log () {
143143
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
144-
echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
144+
# Check to make sure pod doesn't terminate if PID value is empty for any reason
145+
# If PID value is empty postStart hook logs are not recorded
146+
if [ -n "$pid" ]; then
147+
echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
148+
fi
145149
}
146150
log "Info: [poststart] Begin Poststart Hook Execution"
147151
if [[ $POD_NAME != *-0 ]]; then
@@ -168,10 +172,14 @@ spec:
168172
- |
169173
log () {
170174
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
171-
echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
175+
# Check to make sure pod doesn't terminate if PID value is empty for any reason
176+
# If PID value is empty preStart hook logs are not recorded
177+
if [ -n "$pid" ]; then
178+
echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
179+
fi
172180
}
173181
174-
pid=$(ps aux | grep -i '/bin/bas[h] /usr' | awk {'print $2'})
182+
pid=$(pgrep start.marklogic)
175183
log "Info: [prestop] Prestop Hook Execution"
176184
177185
my_host=$(hostname -f)

0 commit comments

Comments
 (0)