From e1b9434dd72bd07778ee2c7fc91ad34018c2b11a Mon Sep 17 00:00:00 2001 From: cloudziu Date: Tue, 24 Nov 2020 16:26:48 +0100 Subject: [PATCH] ES Statefulset empty initContainers fix (#795) Co-authored-by: Julien Mailleret <8582351+jmlrt@users.noreply.github.com> --- elasticsearch/templates/statefulset.yaml | 2 ++ elasticsearch/tests/elasticsearch_test.py | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/elasticsearch/templates/statefulset.yaml b/elasticsearch/templates/statefulset.yaml index 654feded7..70dd1a3cc 100644 --- a/elasticsearch/templates/statefulset.yaml +++ b/elasticsearch/templates/statefulset.yaml @@ -153,6 +153,7 @@ spec: {{ toYaml .Values.imagePullSecrets | indent 8 }} {{- end }} enableServiceLinks: {{ .Values.enableServiceLinks }} + {{- if or (.Values.extraInitContainers) (.Values.sysctlInitContainer.enabled) (.Values.keystore) }} initContainers: {{- if .Values.sysctlInitContainer.enabled }} - name: configure-sysctl @@ -210,6 +211,7 @@ spec: {{ tpl .Values.extraInitContainers . | indent 6 }} {{- else }} {{ toYaml .Values.extraInitContainers | indent 6 }} + {{- end }} {{- end }} {{- end }} containers: diff --git a/elasticsearch/tests/elasticsearch_test.py b/elasticsearch/tests/elasticsearch_test.py index 39c02b307..a55132f64 100755 --- a/elasticsearch/tests/elasticsearch_test.py +++ b/elasticsearch/tests/elasticsearch_test.py @@ -418,10 +418,7 @@ def test_sysctl_init_container_disabled(): enabled: false """ r = helm_template(config) - initContainers = r["statefulset"][uname]["spec"]["template"]["spec"][ - "initContainers" - ] - assert initContainers is None + assert "initContainers" not in r["statefulset"][uname]["spec"]["template"]["spec"] def test_sysctl_init_container_enabled():