From 2cc3673f24b3d745f5c7fefe9051ebd557f211bd Mon Sep 17 00:00:00 2001 From: Jacek Date: Wed, 17 Nov 2021 17:09:46 +0100 Subject: [PATCH] SONAR-15070 Fix error when sometimes setting sonar.search.host causes SQ to fail at start --- .../src/main/java/org/sonar/application/es/EsSettings.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 562fba9d87b..3dd12e655f5 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 @@ -151,14 +151,16 @@ 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, 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())); // we have no use of transport port in non-DCE editions - builder.put(ES_TRANSPORT_HOST_KEY, this.loopbackAddress.getHostAddress()); + // but specified host must be the one listed in: discovery.seed_hosts + // otherwise elasticsearch cannot elect master node + // by default it will be localhost, see: org.sonar.process.ProcessProperties.completeDefaults + builder.put(ES_TRANSPORT_HOST_KEY, searchHost.getHostAddress()); builder.put(ES_TRANSPORT_PORT_KEY, valueOf(transportPort)); } -- 2.39.5