Fix elasticsearch-data shutdown

The shutdown script for the elasticsearch-data container uses a trap
handler to run the steps outlined in the rolling restart procedure [0].
However, when trying to kill the elasticsearch process (step 3), the
script sends the TERM signal to itself.

The traps are handled recursively, causing the entire termination grace
period to be exhausted before the pod is finally removed.

This change updates the trap handler to terminate the child process(es)
instead, and wait for their completion.

0: https://www.elastic.co/guide/en/elasticsearch/reference/7.x/restart-cluster.html

Change-Id: I0c92ea5cce345cff951f044026a2179dcbd5a3e2
This commit is contained in:
Phil Sphicas 2022-03-16 11:48:33 -07:00
parent c3da3a6f79
commit 03e7fedb2b
3 changed files with 12 additions and 2 deletions

View File

@ -15,7 +15,7 @@ apiVersion: v1
appVersion: v7.6.2
description: OpenStack-Helm ElasticSearch
name: elasticsearch
version: 0.2.14
version: 0.2.15
home: https://www.elastic.co/
sources:
- https://github.com/elastic/elasticsearch

View File

@ -133,7 +133,16 @@ function start_data_node () {
# (The only side effect of not doing so is slower start up times. See flush documentation linked above)
echo "Node ${NODE_NAME} is ready to shutdown"
kill -TERM 1
echo "Killing Elasticsearch background processes"
jobs -p | xargs -t -r kill -TERM
wait
# remove the trap handler
trap - TERM EXIT HUP INT
echo "Node ${NODE_NAME} shutdown is complete"
exit 0
}
trap drain_data_node TERM EXIT HUP INT
wait

View File

@ -24,4 +24,5 @@ elasticsearch:
- 0.2.12 Helm 3 - Fix Job labels
- 0.2.13 Update htk requirements
- 0.2.14 Fix cronjob rendering
- 0.2.15 Fix elasticsearch-data shutdown
...