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

Commit

Permalink
[elasticsearch] remove masterTerminationFix (#1183) (#1215)
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 #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 Jun 10, 2021
1 parent 6063608 commit 9834f20
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 @@ -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 | `""` |
Expand Down
58 changes: 0 additions & 58 deletions elasticsearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -362,64 +362,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 @@ -639,26 +639,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 @@ -984,23 +964,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 @@ -263,9 +263,6 @@ ingress:
nameOverride: ""
fullnameOverride: ""

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

lifecycle:
{}
# preStop:
Expand Down

0 comments on commit 9834f20

Please sign in to comment.