From f5a834a4b328790d671c9706782671ee777720ce Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Wed, 17 Apr 2019 16:30:50 +0200 Subject: [PATCH 1/4] remove discovery.zen.ping.unicast.hosts settign on esMajorVersion > 7 --- elasticsearch/templates/statefulset.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/elasticsearch/templates/statefulset.yaml b/elasticsearch/templates/statefulset.yaml index 84f172c2d..d42d89155 100644 --- a/elasticsearch/templates/statefulset.yaml +++ b/elasticsearch/templates/statefulset.yaml @@ -174,8 +174,10 @@ spec: value: "{{ .Values.minimumMasterNodes }}" {{- end }} {{- end }} + {{- if le (int .Values.esMajorVersion) 7 }} - name: discovery.zen.ping.unicast.hosts value: "{{ template "masterService" . }}-headless" + {{- end }} - name: cluster.name value: "{{ .Values.clusterName }}" - name: network.host From 7c40ef477d21eeffd845513576c6ea0469789edf Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Wed, 17 Apr 2019 17:02:39 +0200 Subject: [PATCH 2/4] add discovery.seed_hosts setting --- elasticsearch/templates/statefulset.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/elasticsearch/templates/statefulset.yaml b/elasticsearch/templates/statefulset.yaml index d42d89155..a8e0d72fe 100644 --- a/elasticsearch/templates/statefulset.yaml +++ b/elasticsearch/templates/statefulset.yaml @@ -177,6 +177,9 @@ spec: {{- if le (int .Values.esMajorVersion) 7 }} - name: discovery.zen.ping.unicast.hosts value: "{{ template "masterService" . }}-headless" + {{- else }} + - name: discovery.seed_hosts + value: "{{ template "masterService" . }}-headless" {{- end }} - name: cluster.name value: "{{ .Values.clusterName }}" From d3615d4eb93f0229f2b4542510a4393bf6523fd9 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Wed, 17 Apr 2019 21:50:10 +0200 Subject: [PATCH 3/4] set the change for 7+ versions --- elasticsearch/templates/statefulset.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch/templates/statefulset.yaml b/elasticsearch/templates/statefulset.yaml index a8e0d72fe..726af0145 100644 --- a/elasticsearch/templates/statefulset.yaml +++ b/elasticsearch/templates/statefulset.yaml @@ -174,7 +174,7 @@ spec: value: "{{ .Values.minimumMasterNodes }}" {{- end }} {{- end }} - {{- if le (int .Values.esMajorVersion) 7 }} + {{- if lt (int .Values.esMajorVersion) 7 }} - name: discovery.zen.ping.unicast.hosts value: "{{ template "masterService" . }}-headless" {{- else }} From 4656d9b5becd84114f2227876af88223e36b1f89 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Wed, 17 Apr 2019 21:50:36 +0200 Subject: [PATCH 4/4] add a test, fix some tests --- elasticsearch/tests/elasticsearch_test.py | 26 ++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/elasticsearch/tests/elasticsearch_test.py b/elasticsearch/tests/elasticsearch_test.py index 428e398a3..8162297ee 100755 --- a/elasticsearch/tests/elasticsearch_test.py +++ b/elasticsearch/tests/elasticsearch_test.py @@ -54,7 +54,7 @@ def test_defaults(): uname + '-2,' }, { - 'name': 'discovery.zen.ping.unicast.hosts', + 'name': 'discovery.seed_hosts', 'value': uname + '-headless' }, @@ -200,6 +200,7 @@ def test_overriding_the_image_and_tag(): def test_set_discovery_hosts_to_custom_master_service(): config = ''' +esMajorVersion: 6 masterService: "elasticsearch-custommaster" ''' r = helm_template(config) @@ -207,8 +208,10 @@ def test_set_discovery_hosts_to_custom_master_service(): assert {'name': 'discovery.zen.ping.unicast.hosts', 'value': 'elasticsearch-custommaster-headless'} in env + def test_set_master_service_to_default_nodegroup_name_if_not_set(): config = ''' +esMajorVersion: 6 nodeGroup: "data" ''' r = helm_template(config) @@ -216,8 +219,10 @@ def test_set_master_service_to_default_nodegroup_name_if_not_set(): assert {'name': 'discovery.zen.ping.unicast.hosts', 'value': 'elasticsearch-master-headless'} in env + def test_set_master_service_to_default_nodegroup_name_with_custom_cluster_name(): config = ''' +esMajorVersion: 6 clusterName: "custom" nodeGroup: "data" ''' @@ -245,6 +250,7 @@ def test_set_initial_master_nodes_when_using_v_7(): for e in env: assert e['name'] != 'discovery.zen.minimum_master_nodes' + def test_dont_set_initial_master_nodes_if_not_master_when_using_es_version_7(): config = ''' esMajorVersion: 7 @@ -256,6 +262,24 @@ def test_dont_set_initial_master_nodes_if_not_master_when_using_es_version_7(): for e in env: assert e['name'] != 'cluster.initial_master_nodes' + +def test_set_discovery_seed_host_when_using_v_7(): + config = ''' +esMajorVersion: 7 +roles: + master: "true" +''' + r = helm_template(config) + env = r['statefulset'][uname]['spec']['template']['spec']['containers'][0]['env'] + assert { + 'name': 'discovery.seed_hosts', + 'value': 'elasticsearch-master-headless' + } in env + + for e in env: + assert e['name'] != 'discovery.zen.ping.unicast.hosts' + + def test_enabling_machine_learning_role(): config = ''' roles: