From b786a50e6b45b99bdf0ba95131ddca7fe4a6f707 Mon Sep 17 00:00:00 2001 From: Michael Russell Date: Mon, 1 Jul 2019 10:55:26 +0200 Subject: [PATCH] [elasticsearch] Disable masterTerminationFix by default Closes: #191 This fix which was added for #63 is no longer needed in Elasticsearch > 7.2.0 as this has been fixed upstream. --- elasticsearch/README.md | 1 + elasticsearch/templates/statefulset.yaml | 2 ++ elasticsearch/tests/elasticsearch_test.py | 16 ++++++++++++++++ elasticsearch/values.yaml | 3 +++ 4 files changed, 22 insertions(+) diff --git a/elasticsearch/README.md b/elasticsearch/README.md index 1400fd681..aaad572c7 100644 --- a/elasticsearch/README.md +++ b/elasticsearch/README.md @@ -104,6 +104,7 @@ helm install --name elasticsearch elastic/elasticsearch --version 7.2.0 --set im | `tolerations` | Configurable [tolerations](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/) | `[]` | | `ingress` | Configurable [ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) to expose the Elasticsearch service. See [`values.yaml`](./values.yaml) for an example | `enabled: false` | | `schedulerName` | Name of the [alternate scheduler](https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/#specify-schedulers-for-pods) | `nil` | +| `masterTerminationFix` | A workaround needed for Elasticsearch < 7.2.0 to prevent master status being lost during restarts [#63](https://github.com/elastic/helm-charts/issues/63) | `false` | ## Try it out diff --git a/elasticsearch/templates/statefulset.yaml b/elasticsearch/templates/statefulset.yaml index be2d44f8e..298f4fabe 100644 --- a/elasticsearch/templates/statefulset.yaml +++ b/elasticsearch/templates/statefulset.yaml @@ -222,6 +222,7 @@ spec: {{- if .Values.extraVolumeMounts }} {{ tpl .Values.extraVolumeMounts . | indent 10 }} {{- end }} + {{- if .Values.masterTerminationFix }} {{- if eq .Values.roles.master "true" }} # This sidecar will prevent slow master re-election # https://github.com/elastic/helm-charts/issues/63 @@ -272,3 +273,4 @@ spec: {{ toYaml .Values.extraEnvs | indent 10 }} {{- end }} {{- end }} + {{- end }} diff --git a/elasticsearch/tests/elasticsearch_test.py b/elasticsearch/tests/elasticsearch_test.py index 9422858a2..c367386dc 100755 --- a/elasticsearch/tests/elasticsearch_test.py +++ b/elasticsearch/tests/elasticsearch_test.py @@ -614,3 +614,19 @@ def test_adding_a_nodePort(): r = helm_template(config) assert r['service'][uname]['spec']['ports'][0]['nodePort'] == 30001 + +def test_master_termination_fixed_enabled(): + config = '' + + r = helm_template(config) + + assert len(r['statefulset'][uname]['spec']['template']['spec']['containers']) == 1 + + config = ''' + masterTerminationFix: true + ''' + + r = helm_template(config) + + c = r['statefulset'][uname]['spec']['template']['spec']['containers'][1] + assert c['name'] == 'elasticsearch-master-graceful-termination-handler' diff --git a/elasticsearch/values.yaml b/elasticsearch/values.yaml index 2c9472196..c9646a6cf 100755 --- a/elasticsearch/values.yaml +++ b/elasticsearch/values.yaml @@ -173,3 +173,6 @@ ingress: nameOverride: "" fullnameOverride: "" + +# https://github.com/elastic/helm-charts/issues/63 +masterTerminationFix: false