From 9efaf25d21f28e628687661f47f7e6f8ce5f13a2 Mon Sep 17 00:00:00 2001 From: Peter Brachwitz Date: Tue, 16 Aug 2022 10:26:16 +0200 Subject: [PATCH] Elasticsearch: always set discovery.seed_hosts to empty array (#5950) This is to avoid confusing error messages about nodes not being able to connect to localhost for discovery. Co-authored-by: Thibault Richard --- .../elasticsearch/reserved-settings.asciidoc | 2 ++ pkg/apis/elasticsearch/v1/fields.go | 3 +++ .../elasticsearch/nodespec/podspec_test.go | 16 ++++++++-------- .../elasticsearch/settings/merged_config.go | 3 +++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/orchestrating-elastic-stack-applications/elasticsearch/reserved-settings.asciidoc b/docs/orchestrating-elastic-stack-applications/elasticsearch/reserved-settings.asciidoc index 410d69528d..68d8e2b596 100644 --- a/docs/orchestrating-elastic-stack-applications/elasticsearch/reserved-settings.asciidoc +++ b/docs/orchestrating-elastic-stack-applications/elasticsearch/reserved-settings.asciidoc @@ -11,6 +11,8 @@ endif::[] The following Elasticsearch settings are managed by ECK: * `cluster.name` +* `discovery.seed_hosts` +* `discovery.seed_providers` * `discovery.zen.minimum_master_nodes` deprecated[7.0] * `cluster.initial_master_nodes` added[7.0] * `network.host` diff --git a/pkg/apis/elasticsearch/v1/fields.go b/pkg/apis/elasticsearch/v1/fields.go index 6321b9128f..59f0705d63 100644 --- a/pkg/apis/elasticsearch/v1/fields.go +++ b/pkg/apis/elasticsearch/v1/fields.go @@ -12,6 +12,7 @@ const ( DiscoveryZenHostsProvider = "discovery.zen.hosts_provider" // ES < 7.X DiscoverySeedProviders = "discovery.seed_providers" // ES >= 7.X + DiscoverySeedHosts = "discovery.seed_hosts" // ES >= 7.X NetworkHost = "network.host" NetworkPublishHost = "network.publish_host" @@ -50,6 +51,8 @@ const ( var UnsupportedSettings = []string{ ClusterName, + DiscoverySeedHosts, + DiscoverySeedProviders, DiscoveryZenMinimumMasterNodes, ClusterInitialMasterNodes, NetworkHost, diff --git a/pkg/controller/elasticsearch/nodespec/podspec_test.go b/pkg/controller/elasticsearch/nodespec/podspec_test.go index 40ceec72f0..caf04540f0 100644 --- a/pkg/controller/elasticsearch/nodespec/podspec_test.go +++ b/pkg/controller/elasticsearch/nodespec/podspec_test.go @@ -277,7 +277,7 @@ func TestBuildPodTemplateSpec(t *testing.T) { "pod-template-label-name": "pod-template-label-value", }, Annotations: map[string]string{ - "elasticsearch.k8s.elastic.co/config-hash": "957591218", + "elasticsearch.k8s.elastic.co/config-hash": "3893049321", "pod-template-annotation-name": "pod-template-annotation-value", "co.elastic.logs/module": "elasticsearch", }, @@ -339,7 +339,7 @@ func Test_buildAnnotations(t *testing.T) { { name: "Sample Elasticsearch resource", expectedAnnotations: map[string]string{ - "elasticsearch.k8s.elastic.co/config-hash": "1382203021", + "elasticsearch.k8s.elastic.co/config-hash": "533641620", }, }, { @@ -352,7 +352,7 @@ func Test_buildAnnotations(t *testing.T) { }, }, expectedAnnotations: map[string]string{ - "elasticsearch.k8s.elastic.co/config-hash": "2958662249", + "elasticsearch.k8s.elastic.co/config-hash": "3131886472", }, }, { @@ -361,7 +361,7 @@ func Test_buildAnnotations(t *testing.T) { esAnnotations: map[string]string{"eck.k8s.elastic.co/downward-node-labels": "topology.kubernetes.io/zone"}, }, expectedAnnotations: map[string]string{ - "elasticsearch.k8s.elastic.co/config-hash": "481468635", + "elasticsearch.k8s.elastic.co/config-hash": "757126536", }, }, { @@ -370,7 +370,7 @@ func Test_buildAnnotations(t *testing.T) { esAnnotations: map[string]string{"eck.k8s.elastic.co/downward-node-labels": "topology.kubernetes.io/zone,topology.kubernetes.io/region"}, }, expectedAnnotations: map[string]string{ - "elasticsearch.k8s.elastic.co/config-hash": "3276316785", + "elasticsearch.k8s.elastic.co/config-hash": "3605766330", }, }, { @@ -382,7 +382,7 @@ func Test_buildAnnotations(t *testing.T) { scriptsVersion: "84", }, expectedAnnotations: map[string]string{ - "elasticsearch.k8s.elastic.co/config-hash": "3641963559", + "elasticsearch.k8s.elastic.co/config-hash": "1607725946", }, }, { @@ -394,7 +394,7 @@ func Test_buildAnnotations(t *testing.T) { scriptsVersion: "84", }, expectedAnnotations: map[string]string{ - "elasticsearch.k8s.elastic.co/config-hash": "3625185940", + "elasticsearch.k8s.elastic.co/config-hash": "1624503565", }, }, { @@ -406,7 +406,7 @@ func Test_buildAnnotations(t *testing.T) { scriptsVersion: "85", }, expectedAnnotations: map[string]string{ - "elasticsearch.k8s.elastic.co/config-hash": "3917140820", + "elasticsearch.k8s.elastic.co/config-hash": "3194693445", }, }, } diff --git a/pkg/controller/elasticsearch/settings/merged_config.go b/pkg/controller/elasticsearch/settings/merged_config.go index ee421c9600..3369d9d107 100644 --- a/pkg/controller/elasticsearch/settings/merged_config.go +++ b/pkg/controller/elasticsearch/settings/merged_config.go @@ -75,6 +75,9 @@ func baseConfig(clusterName string, ver version.Version, ipFamily corev1.IPFamil cfg[esv1.DiscoveryZenHostsProvider] = fileProvider } else { cfg[esv1.DiscoverySeedProviders] = fileProvider + // to avoid misleading error messages about the inability to connect to localhost for discovery despite us using + // file based discovery + cfg[esv1.DiscoverySeedHosts] = []string{} } return &CanonicalConfig{common.MustCanonicalConfig(cfg)}