From fe454d78281b8beb219028464ed14cd0622e0986 Mon Sep 17 00:00:00 2001 From: Julien Mailleret <8582351+jmlrt@users.noreply.github.com> Date: Wed, 12 May 2021 15:40:44 +0200 Subject: [PATCH] [elasticsearch] remove masterTerminationFix (#1183) * [elasticsearch] fix values table formatting * [elasticsearch] remove masterTerminationFix This commit removes the `masterTerminationFix` side-car container introduced in #63 to fix slow elections issues when master node is deleted. This workaround is no more needed since Elasticsearch 7.2. --- elasticsearch/README.md | 1 - elasticsearch/templates/statefulset.yaml | 58 ----------------------- elasticsearch/tests/elasticsearch_test.py | 37 --------------- elasticsearch/values.yaml | 3 -- 4 files changed, 99 deletions(-) diff --git a/elasticsearch/README.md b/elasticsearch/README.md index da024dce6..a0d2e13ee 100644 --- a/elasticsearch/README.md +++ b/elasticsearch/README.md @@ -137,7 +137,6 @@ support multiple versions with minimal changes. | `labels` | Configurable [labels][] applied to all Elasticsearch pods | `{}` | | `lifecycle` | Allows you to add [lifecycle hooks][]. See [values.yaml][] for an example of the formatting | `{}` | | `masterService` | The service name used to connect to the masters. You only need to set this if your master `nodeGroup` is set to something other than `master`. See [Clustering and Node Discovery][] for more information | `""` | -| `masterTerminationFix` | A workaround needed for Elasticsearch < 7.2 to prevent master status being lost during restarts [#63][] | `false` | | `maxUnavailable` | The [maxUnavailable][] value for the pod disruption budget. By default this will prevent Kubernetes from having more than 1 unhealthy pod in the node group | `1` | | `minimumMasterNodes` | The value for [discovery.zen.minimum_master_nodes][]. Should be set to `(master_eligible_nodes / 2) + 1`. Ignored in Elasticsearch versions >= 7 | `2` | | `nameOverride` | Overrides the `clusterName` when used in the naming of resources | `""` | diff --git a/elasticsearch/templates/statefulset.yaml b/elasticsearch/templates/statefulset.yaml index e44a01624..0e01c165c 100644 --- a/elasticsearch/templates/statefulset.yaml +++ b/elasticsearch/templates/statefulset.yaml @@ -360,64 +360,6 @@ spec: {{ toYaml .Values.extraVolumeMounts | indent 10 }} {{- end }} {{- 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 - - name: elasticsearch-master-graceful-termination-handler - image: "{{ .Values.image }}:{{ .Values.imageTag }}" - imagePullPolicy: "{{ .Values.imagePullPolicy }}" - command: - - "sh" - - -c - - | - #!/usr/bin/env bash - set -eo pipefail - - http () { - local path="${1}" - if [ -n "${ELASTIC_USERNAME}" ] && [ -n "${ELASTIC_PASSWORD}" ]; then - BASIC_AUTH="-u ${ELASTIC_USERNAME}:${ELASTIC_PASSWORD}" - else - BASIC_AUTH='' - fi - curl -XGET -s -k --fail ${BASIC_AUTH} {{ .Values.protocol }}://{{ template "elasticsearch.masterService" . }}:{{ .Values.httpPort }}${path} - } - - cleanup () { - while true ; do - local master="$(http "/_cat/master?h=node" || echo "")" - if [[ $master == "{{ template "elasticsearch.masterService" . }}"* && $master != "${NODE_NAME}" ]]; then - echo "This node is not master." - break - fi - echo "This node is still master, waiting gracefully for it to step down" - sleep 1 - done - - exit 0 - } - - trap cleanup SIGTERM - - sleep infinity & - wait $! - resources: -{{ toYaml .Values.sidecarResources | indent 10 }} - env: - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - {{- if .Values.extraEnvs }} -{{ toYaml .Values.extraEnvs | indent 10 }} - {{- end }} - {{- if .Values.envFrom }} - envFrom: -{{ toYaml .Values.envFrom | indent 10 }} - {{- end }} - {{- end }} - {{- end }} {{- if .Values.lifecycle }} lifecycle: {{ toYaml .Values.lifecycle | indent 10 }} diff --git a/elasticsearch/tests/elasticsearch_test.py b/elasticsearch/tests/elasticsearch_test.py index 2c2bb06bd..f48e70865 100755 --- a/elasticsearch/tests/elasticsearch_test.py +++ b/elasticsearch/tests/elasticsearch_test.py @@ -640,26 +640,6 @@ def test_adding_resources_to_initcontainer(): } -def test_adding_resources_to_sidecar_container(): - config = """ -masterTerminationFix: true -sidecarResources: - limits: - cpu: "100m" - memory: "128Mi" - requests: - cpu: "100m" - memory: "128Mi" -""" - r = helm_template(config) - i = r["statefulset"][uname]["spec"]["template"]["spec"]["containers"][1] - - assert i["resources"] == { - "requests": {"cpu": "100m", "memory": "128Mi"}, - "limits": {"cpu": "100m", "memory": "128Mi"}, - } - - def test_adding_a_node_affinity(): config = """ nodeAffinity: @@ -985,23 +965,6 @@ def test_adding_load_balancer_source_ranges(): assert ranges[1] == "192.168.1.0/24" -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" - - def test_lifecycle_hooks(): config = "" r = helm_template(config) diff --git a/elasticsearch/values.yaml b/elasticsearch/values.yaml index f097d1109..06328b62b 100755 --- a/elasticsearch/values.yaml +++ b/elasticsearch/values.yaml @@ -263,9 +263,6 @@ ingress: nameOverride: "" fullnameOverride: "" -# https://github.com/elastic/helm-charts/issues/63 -masterTerminationFix: false - lifecycle: {} # preStop: