Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
[elasticsearch] remove masterTerminationFix (elastic#1183)
Browse files Browse the repository at this point in the history
* [elasticsearch] fix values table formatting

* [elasticsearch] remove masterTerminationFix

This commit removes the `masterTerminationFix` side-car container
introduced in elastic#63 to fix slow elections issues when master node is
deleted. This workaround is no more needed since Elasticsearch 7.2.
  • Loading branch information
jmlrt committed May 25, 2021
1 parent 2fafdf1 commit 49621c8
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 99 deletions.
1 change: 0 additions & 1 deletion elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,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 | `""` |
Expand Down
58 changes: 0 additions & 58 deletions elasticsearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -355,64 +355,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 }}
Expand Down
37 changes: 0 additions & 37 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,26 +588,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:
Expand Down Expand Up @@ -933,23 +913,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)
Expand Down
3 changes: 0 additions & 3 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,6 @@ ingress:
nameOverride: ""
fullnameOverride: ""

# https://github.com/elastic/helm-charts/issues/63
masterTerminationFix: false

lifecycle: {}
# preStop:
# exec:
Expand Down

0 comments on commit 49621c8

Please sign in to comment.