From 55ba8c6100ba8afc608958fce60dcc38a5a709a2 Mon Sep 17 00:00:00 2001 From: Michal Duda Date: Fri, 30 Oct 2020 13:31:18 +0100 Subject: SONAR-12686 Fix Elasticsearch properties for a single node - https://www.elastic.co/guide/en/elasticsearch/reference/7.x/breaking-changes-7.0.html#_discovery_configuration_is_required_in_production --- .../src/main/java/org/sonar/application/es/EsSettings.java | 4 +++- .../src/test/java/org/sonar/application/es/EsSettingsTest.java | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'server/sonar-main') diff --git a/server/sonar-main/src/main/java/org/sonar/application/es/EsSettings.java b/server/sonar-main/src/main/java/org/sonar/application/es/EsSettings.java index 51323964cae..dc3b606d1c4 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/es/EsSettings.java +++ b/server/sonar-main/src/main/java/org/sonar/application/es/EsSettings.java @@ -108,7 +108,9 @@ public class EsSettings { int searchPort = Integer.parseInt(props.nonNullValue(SEARCH_PORT.getKey())); builder.put(ES_HTTP_HOST_KEY, searchHost.getHostAddress()); builder.put(ES_HTTP_PORT_KEY, valueOf(searchPort)); - builder.put(ES_NETWORK_HOST_KEY, valueOf(searchHost.getHostAddress())); + builder.put(ES_NETWORK_HOST_KEY, searchHost.getHostAddress()); + builder.put("discovery.seed_hosts", searchHost.getHostAddress()); + builder.put("cluster.initial_master_nodes", searchHost.getHostAddress()); int transportPort = Integer.parseInt(props.nonNullValue(ES_PORT.getKey())); diff --git a/server/sonar-main/src/test/java/org/sonar/application/es/EsSettingsTest.java b/server/sonar-main/src/test/java/org/sonar/application/es/EsSettingsTest.java index f3722d1332a..af87c10b721 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/es/EsSettingsTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/es/EsSettingsTest.java @@ -150,14 +150,15 @@ public class EsSettingsTest { .containsEntry("http.host", "127.0.0.1") // no cluster, but cluster and node names are set though .containsEntry("cluster.name", "sonarqube") - .containsEntry("node.name", "sonarqube"); + .containsEntry("node.name", "sonarqube") + .containsEntry("discovery.seed_hosts", "127.0.0.1") + .containsEntry("cluster.initial_master_nodes", "127.0.0.1"); assertThat(generated.get("path.data")).isNotNull(); assertThat(generated.get("path.logs")).isNotNull(); assertThat(generated.get("path.home")).isNull(); assertThat(generated.get("path.conf")).isNull(); - assertThat(generated.get("discovery.seed_hosts")).isNull(); assertThat(generated) .containsEntry("discovery.initial_state_timeout", "30s") .containsEntry("action.auto_create_index", "false"); -- cgit v1.2.3