Skip to content

Commit

Permalink
Elasticsearch: always set discovery.seed_hosts to empty array (elasti…
Browse files Browse the repository at this point in the history
…c#5950)

This is to avoid confusing error messages about nodes not being able to connect to localhost for discovery.

Co-authored-by: Thibault Richard <thbkrkr@users.noreply.github.com>
  • Loading branch information
2 people authored and fantapsody committed Jan 3, 2023
1 parent 70ccd56 commit 9efaf25
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/elasticsearch/v1/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -50,6 +51,8 @@ const (

var UnsupportedSettings = []string{
ClusterName,
DiscoverySeedHosts,
DiscoverySeedProviders,
DiscoveryZenMinimumMasterNodes,
ClusterInitialMasterNodes,
NetworkHost,
Expand Down
16 changes: 8 additions & 8 deletions pkg/controller/elasticsearch/nodespec/podspec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down Expand Up @@ -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",
},
},
{
Expand All @@ -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",
},
},
{
Expand All @@ -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",
},
},
{
Expand All @@ -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",
},
},
{
Expand All @@ -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",
},
},
{
Expand All @@ -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",
},
},
{
Expand All @@ -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",
},
},
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/elasticsearch/settings/merged_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down

0 comments on commit 9efaf25

Please sign in to comment.