From 6812a8ebf0692854633c089e8e219278a483f25e Mon Sep 17 00:00:00 2001 From: Peter Brachwitz Date: Fri, 12 Aug 2022 15:07:44 +0200 Subject: [PATCH 1/4] Elasticsearch: alwasy set discovery.seed_hosts to empty array --- pkg/apis/elasticsearch/v1/fields.go | 1 + .../elasticsearch/nodespec/podspec_test.go | 16 ++++++++-------- .../elasticsearch/settings/merged_config.go | 4 ++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pkg/apis/elasticsearch/v1/fields.go b/pkg/apis/elasticsearch/v1/fields.go index 6321b9128f..1f14acd2e2 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" NetworkHost = "network.host" NetworkPublishHost = "network.publish_host" 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..a1c3ba221f 100644 --- a/pkg/controller/elasticsearch/settings/merged_config.go +++ b/pkg/controller/elasticsearch/settings/merged_config.go @@ -67,6 +67,10 @@ func baseConfig(clusterName string, ver version.Version, ipFamily corev1.IPFamil esv1.PathData: volume.ElasticsearchDataMountPath, esv1.PathLogs: volume.ElasticsearchLogsMountPath, + + // to avoid misleading error messages about the inability to connect to localhost for discovery despite us using + // file based discovery + esv1.DiscoverySeedHosts: []string{}, } // seed hosts setting name changed starting ES 7.X From 2d2e0f9544cdd4d2deb04e83f402228f11ee10cc Mon Sep 17 00:00:00 2001 From: Peter Brachwitz Date: Fri, 12 Aug 2022 16:54:27 +0200 Subject: [PATCH 2/4] Make discovery settings reserved --- .../elasticsearch/reserved-settings.asciidoc | 2 ++ pkg/apis/elasticsearch/v1/fields.go | 2 ++ 2 files changed, 4 insertions(+) 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 1f14acd2e2..d46084e6f1 100644 --- a/pkg/apis/elasticsearch/v1/fields.go +++ b/pkg/apis/elasticsearch/v1/fields.go @@ -51,6 +51,8 @@ const ( var UnsupportedSettings = []string{ ClusterName, + DiscoverySeedHosts, + DiscoverySeedProviders, DiscoveryZenMinimumMasterNodes, ClusterInitialMasterNodes, NetworkHost, From 869db491410c90dcdcc018c596ed174373eadf79 Mon Sep 17 00:00:00 2001 From: Peter Brachwitz Date: Fri, 12 Aug 2022 17:25:45 +0200 Subject: [PATCH 3/4] Make this setting > 7 only --- pkg/controller/elasticsearch/settings/merged_config.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/controller/elasticsearch/settings/merged_config.go b/pkg/controller/elasticsearch/settings/merged_config.go index a1c3ba221f..3369d9d107 100644 --- a/pkg/controller/elasticsearch/settings/merged_config.go +++ b/pkg/controller/elasticsearch/settings/merged_config.go @@ -67,10 +67,6 @@ func baseConfig(clusterName string, ver version.Version, ipFamily corev1.IPFamil esv1.PathData: volume.ElasticsearchDataMountPath, esv1.PathLogs: volume.ElasticsearchLogsMountPath, - - // to avoid misleading error messages about the inability to connect to localhost for discovery despite us using - // file based discovery - esv1.DiscoverySeedHosts: []string{}, } // seed hosts setting name changed starting ES 7.X @@ -79,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)} From 5767082fdcdc8e352a64b5ab6f7cc03f21ceead4 Mon Sep 17 00:00:00 2001 From: Peter Brachwitz Date: Fri, 12 Aug 2022 19:35:56 +0200 Subject: [PATCH 4/4] Update pkg/apis/elasticsearch/v1/fields.go Co-authored-by: Thibault Richard --- pkg/apis/elasticsearch/v1/fields.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apis/elasticsearch/v1/fields.go b/pkg/apis/elasticsearch/v1/fields.go index d46084e6f1..59f0705d63 100644 --- a/pkg/apis/elasticsearch/v1/fields.go +++ b/pkg/apis/elasticsearch/v1/fields.go @@ -12,7 +12,7 @@ const ( DiscoveryZenHostsProvider = "discovery.zen.hosts_provider" // ES < 7.X DiscoverySeedProviders = "discovery.seed_providers" // ES >= 7.X - DiscoverySeedHosts = "discovery.seed_hosts" + DiscoverySeedHosts = "discovery.seed_hosts" // ES >= 7.X NetworkHost = "network.host" NetworkPublishHost = "network.publish_host"