From 03e7fedb2b511dde868533acf57cd102ae87d812 Mon Sep 17 00:00:00 2001 From: Phil Sphicas Date: Wed, 16 Mar 2022 11:48:33 -0700 Subject: [PATCH] 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 --- elasticsearch/Chart.yaml | 2 +- elasticsearch/templates/bin/_elasticsearch.sh.tpl | 11 ++++++++++- releasenotes/notes/elasticsearch.yaml | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/elasticsearch/Chart.yaml b/elasticsearch/Chart.yaml index 9c22cf75dd..ffde00b76b 100644 --- a/elasticsearch/Chart.yaml +++ b/elasticsearch/Chart.yaml @@ -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 diff --git a/elasticsearch/templates/bin/_elasticsearch.sh.tpl b/elasticsearch/templates/bin/_elasticsearch.sh.tpl index 778f276577..dcf32f5644 100644 --- a/elasticsearch/templates/bin/_elasticsearch.sh.tpl +++ b/elasticsearch/templates/bin/_elasticsearch.sh.tpl @@ -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 diff --git a/releasenotes/notes/elasticsearch.yaml b/releasenotes/notes/elasticsearch.yaml index 9b6ba69d94..907550ce63 100644 --- a/releasenotes/notes/elasticsearch.yaml +++ b/releasenotes/notes/elasticsearch.yaml @@ -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 ...