Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.

Commit 9834f20

Browse files
authored
[elasticsearch] remove masterTerminationFix (#1183) (#1215)
* [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.
1 parent 6063608 commit 9834f20

File tree

4 files changed

+0
-99
lines changed

4 files changed

+0
-99
lines changed

elasticsearch/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ support multiple versions with minimal changes.
137137
| `labels` | Configurable [labels][] applied to all Elasticsearch pods | `{}` |
138138
| `lifecycle` | Allows you to add [lifecycle hooks][]. See [values.yaml][] for an example of the formatting | `{}` |
139139
| `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 | `""` |
140-
| `masterTerminationFix` | A workaround needed for Elasticsearch < 7.2 to prevent master status being lost during restarts [#63][] | `false` |
141140
| `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` |
142141
| `minimumMasterNodes` | The value for [discovery.zen.minimum_master_nodes][]. Should be set to `(master_eligible_nodes / 2) + 1`. Ignored in Elasticsearch versions >= 7 | `2` |
143142
| `nameOverride` | Overrides the `clusterName` when used in the naming of resources | `""` |

elasticsearch/templates/statefulset.yaml

-58
Original file line numberDiff line numberDiff line change
@@ -362,64 +362,6 @@ spec:
362362
{{ toYaml .Values.extraVolumeMounts | indent 10 }}
363363
{{- end }}
364364
{{- end }}
365-
{{- if .Values.masterTerminationFix }}
366-
{{- if eq .Values.roles.master "true" }}
367-
# This sidecar will prevent slow master re-election
368-
# https://github.com/elastic/helm-charts/issues/63
369-
- name: elasticsearch-master-graceful-termination-handler
370-
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
371-
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
372-
command:
373-
- "sh"
374-
- -c
375-
- |
376-
#!/usr/bin/env bash
377-
set -eo pipefail
378-
379-
http () {
380-
local path="${1}"
381-
if [ -n "${ELASTIC_USERNAME}" ] && [ -n "${ELASTIC_PASSWORD}" ]; then
382-
BASIC_AUTH="-u ${ELASTIC_USERNAME}:${ELASTIC_PASSWORD}"
383-
else
384-
BASIC_AUTH=''
385-
fi
386-
curl -XGET -s -k --fail ${BASIC_AUTH} {{ .Values.protocol }}://{{ template "elasticsearch.masterService" . }}:{{ .Values.httpPort }}${path}
387-
}
388-
389-
cleanup () {
390-
while true ; do
391-
local master="$(http "/_cat/master?h=node" || echo "")"
392-
if [[ $master == "{{ template "elasticsearch.masterService" . }}"* && $master != "${NODE_NAME}" ]]; then
393-
echo "This node is not master."
394-
break
395-
fi
396-
echo "This node is still master, waiting gracefully for it to step down"
397-
sleep 1
398-
done
399-
400-
exit 0
401-
}
402-
403-
trap cleanup SIGTERM
404-
405-
sleep infinity &
406-
wait $!
407-
resources:
408-
{{ toYaml .Values.sidecarResources | indent 10 }}
409-
env:
410-
- name: NODE_NAME
411-
valueFrom:
412-
fieldRef:
413-
fieldPath: metadata.name
414-
{{- if .Values.extraEnvs }}
415-
{{ toYaml .Values.extraEnvs | indent 10 }}
416-
{{- end }}
417-
{{- if .Values.envFrom }}
418-
envFrom:
419-
{{ toYaml .Values.envFrom | indent 10 }}
420-
{{- end }}
421-
{{- end }}
422-
{{- end }}
423365
{{- if .Values.lifecycle }}
424366
lifecycle:
425367
{{ toYaml .Values.lifecycle | indent 10 }}

elasticsearch/tests/elasticsearch_test.py

-37
Original file line numberDiff line numberDiff line change
@@ -639,26 +639,6 @@ def test_adding_resources_to_initcontainer():
639639
}
640640

641641

642-
def test_adding_resources_to_sidecar_container():
643-
config = """
644-
masterTerminationFix: true
645-
sidecarResources:
646-
limits:
647-
cpu: "100m"
648-
memory: "128Mi"
649-
requests:
650-
cpu: "100m"
651-
memory: "128Mi"
652-
"""
653-
r = helm_template(config)
654-
i = r["statefulset"][uname]["spec"]["template"]["spec"]["containers"][1]
655-
656-
assert i["resources"] == {
657-
"requests": {"cpu": "100m", "memory": "128Mi"},
658-
"limits": {"cpu": "100m", "memory": "128Mi"},
659-
}
660-
661-
662642
def test_adding_a_node_affinity():
663643
config = """
664644
nodeAffinity:
@@ -984,23 +964,6 @@ def test_adding_load_balancer_source_ranges():
984964
assert ranges[1] == "192.168.1.0/24"
985965

986966

987-
def test_master_termination_fixed_enabled():
988-
config = ""
989-
990-
r = helm_template(config)
991-
992-
assert len(r["statefulset"][uname]["spec"]["template"]["spec"]["containers"]) == 1
993-
994-
config = """
995-
masterTerminationFix: true
996-
"""
997-
998-
r = helm_template(config)
999-
1000-
c = r["statefulset"][uname]["spec"]["template"]["spec"]["containers"][1]
1001-
assert c["name"] == "elasticsearch-master-graceful-termination-handler"
1002-
1003-
1004967
def test_lifecycle_hooks():
1005968
config = ""
1006969
r = helm_template(config)

elasticsearch/values.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,6 @@ ingress:
263263
nameOverride: ""
264264
fullnameOverride: ""
265265

266-
# https://github.com/elastic/helm-charts/issues/63
267-
masterTerminationFix: false
268-
269266
lifecycle:
270267
{}
271268
# preStop:

0 commit comments

Comments
 (0)