Skip to content

Commit

Permalink
Default allow_older_versions to true (#36884)
Browse files Browse the repository at this point in the history
* default allow_older_versions to true

* fix removed file

* fix error message

* Changing tests according to behavior change

* update docs

* add changelog

---------

Co-authored-by: Pierre HILBERT <pierre.hilbert@elastic.co>
  • Loading branch information
fearful-symmetry and pierrehilbert authored Oct 19, 2023
1 parent deb7d42 commit e39b37e
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 52 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ is collected by it.
- Add support for AWS external IDs. {issue}36321[36321] {pull}36322[36322]
- [Enhanncement for host.ip and host.mac] Disabling netinfo.enabled option of add-host-metadata processor {pull}36506[36506]
Setting environmental variable ELASTIC_NETINFO:false in Elastic Agent pod will disable the netinfo.enabled option of add_host_metadata processor
- Beats will now connect to older Elasticsearch instances by default {pull}36884[36884]

*Auditbeat*

Expand Down
5 changes: 2 additions & 3 deletions auditbeat/auditbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# auditbeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents auditbeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down
5 changes: 2 additions & 3 deletions filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1621,9 +1621,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# filebeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents filebeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down
5 changes: 2 additions & 3 deletions heartbeat/heartbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# heartbeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents heartbeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down
5 changes: 2 additions & 3 deletions libbeat/_meta/config/output-elasticsearch.reference.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# {{.BeatName}} expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents {{.BeatName}} from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

{{include "ssl.reference.yml.tmpl" . | indent 2 }}

Expand Down
10 changes: 6 additions & 4 deletions libbeat/cmd/instance/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -1028,16 +1028,18 @@ func (b *Beat) loadDashboards(ctx context.Context, force bool) error {
func (b *Beat) registerESVersionCheckCallback() error {
_, err := elasticsearch.RegisterGlobalCallback(func(conn *eslegclient.Connection) error {
if !isElasticsearchOutput(b.Config.Output.Name()) {
return errors.New("Elasticsearch output is not configured")
return errors.New("elasticsearch output is not configured")
}
if b.isConnectionToOlderVersionAllowed() {
// if we allow older versions, return early and don't check versions
// versions don't matter on serverless, so always bypass
if b.isConnectionToOlderVersionAllowed() || conn.IsServerless() {
return nil
}

esVersion := conn.GetVersion()
beatVersion, err := libversion.New(b.Info.Version)
if err != nil {
return err
return fmt.Errorf("error fetching version from elasticsearch: %w", err)
}
if esVersion.LessThanMajorMinor(beatVersion) {
return fmt.Errorf("%w ES=%s, Beat=%s", elasticsearch.ErrTooOld, esVersion.String(), b.Info.Version)
Expand All @@ -1051,7 +1053,7 @@ func (b *Beat) registerESVersionCheckCallback() error {
func (b *Beat) isConnectionToOlderVersionAllowed() bool {
config := struct {
AllowOlder bool `config:"allow_older_versions"`
}{false}
}{true}

_ = b.Config.Output.Config().Unpack(&config)

Expand Down
6 changes: 3 additions & 3 deletions libbeat/cmd/instance/beat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func TestReloader(t *testing.T) {
elasticsearch:
hosts: ["https://127.0.0.1:9200"]
username: "elastic"
allow_older_versions: true
allow_older_versions: false
`
c, err := config.NewConfigWithYAML([]byte(cfg), cfg)
require.NoError(t, err)
Expand All @@ -248,13 +248,13 @@ elasticsearch:
reloader := b.makeOutputReloader(m)

require.False(t, b.Config.Output.IsSet(), "the output should not be set yet")
require.False(t, b.isConnectionToOlderVersionAllowed(), "the flag should not be present in the empty configuration")
require.True(t, b.isConnectionToOlderVersionAllowed(), "allow_older_versions flag should be true from 8.11")
err = reloader.Reload(update)
require.NoError(t, err)
require.True(t, b.Config.Output.IsSet(), "now the output should be set")
require.Equal(t, outCfg, b.Config.Output.Config())
require.Same(t, c, m.cfg.Config)
require.True(t, b.isConnectionToOlderVersionAllowed(), "the flag should be present")
require.False(t, b.isConnectionToOlderVersionAllowed(), "allow_older_versions flag should now be set to false")
})
}

Expand Down
5 changes: 2 additions & 3 deletions metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1360,9 +1360,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# metricbeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents metricbeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down
5 changes: 2 additions & 3 deletions packetbeat/packetbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -991,9 +991,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# packetbeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents packetbeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down
5 changes: 2 additions & 3 deletions winlogbeat/winlogbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# winlogbeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents winlogbeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down
5 changes: 2 additions & 3 deletions x-pack/auditbeat/auditbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# auditbeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents auditbeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down
5 changes: 2 additions & 3 deletions x-pack/filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3991,9 +3991,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# filebeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents filebeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down
5 changes: 2 additions & 3 deletions x-pack/functionbeat/functionbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# functionbeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents functionbeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down
5 changes: 2 additions & 3 deletions x-pack/heartbeat/heartbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# heartbeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents heartbeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down
5 changes: 2 additions & 3 deletions x-pack/metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1921,9 +1921,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# metricbeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents metricbeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down
5 changes: 2 additions & 3 deletions x-pack/osquerybeat/osquerybeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# osquerybeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents osquerybeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down
5 changes: 2 additions & 3 deletions x-pack/packetbeat/packetbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -991,9 +991,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# packetbeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents packetbeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down
5 changes: 2 additions & 3 deletions x-pack/winlogbeat/winlogbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,8 @@ output.elasticsearch:
# Configure HTTP request timeout before failing a request to Elasticsearch.
#timeout: 90

# winlogbeat expects Elasticsearch to be the same version or newer than the Beat.
# Lift the version restriction by setting allow_older_versions to true.
#allow_older_versions: false
# Prevents winlogbeat from connecting to older Elasticsearch versions when set to `false`
#allow_older_versions: true

# Use SSL settings for HTTPS.
#ssl.enabled: true
Expand Down

0 comments on commit e39b37e

Please sign in to comment.