diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 7d527872f403..b83ee0bededa 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -42,6 +42,8 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...main[Check the HEAD dif - Update docker/distribution dependency library to fix a security issues concerning OCI Manifest Type Confusion Issue. {pull}30462[30462] - Fixes Beats crashing when glibc >= 2.35 is used {issue}30576[30576] - Log errors when parsing and applying config blocks and if the input is disabled. {pull}30534[30534] +- Wildcard fields no longer have a default ignore_above setting of 1024. {issue}30096[30096] {pull}30668[30668] +- Ignore bugfix version when running version compatibility check against Elasticsearch. {pull}30746[30746] *Auditbeat* diff --git a/libbeat/cmd/instance/beat.go b/libbeat/cmd/instance/beat.go index 179f75b60ee9..badffd9a7884 100644 --- a/libbeat/cmd/instance/beat.go +++ b/libbeat/cmd/instance/beat.go @@ -870,6 +870,7 @@ func (b *Beat) warnAboutElasticsearchVersion() { } elasticsearch.RegisterGlobalCallback(func(conn *eslegclient.Connection) error { +<<<<<<< HEAD warnAboutOldES.Do(func() { esVersion := conn.GetVersion() beatVersion, err := common.NewVersion(b.Info.Version) @@ -882,6 +883,16 @@ func (b *Beat) warnAboutElasticsearchVersion() { logp.Warn("Connecting to older version of Elasticsearch. From 8.1, connecting to older versions will be disabled by default.") } }) +======= + esVersion := conn.GetVersion() + beatVersion, err := common.NewVersion(b.Info.Version) + if err != nil { + return err + } + if esVersion.LessThanMajorMinor(beatVersion) { + return fmt.Errorf("%v ES=%s, Beat=%s.", elasticsearch.ErrTooOld, esVersion.String(), b.Info.Version) + } +>>>>>>> 46be42e7d5 (Ignore bugfix version when running version compatibility check against Elasticsearch (#30746)) return nil }) } diff --git a/libbeat/common/version.go b/libbeat/common/version.go index 366611531aec..9f1e5caec1ee 100644 --- a/libbeat/common/version.go +++ b/libbeat/common/version.go @@ -121,15 +121,28 @@ func (v *Version) LessThanOrEqual(withMeta bool, v1 *Version) bool { // LessThan returns true if v is strictly smaller than v1. When comparing, the major, // minor and bugfix numbers are compared in order. The meta part is not taken into account. func (v *Version) LessThan(v1 *Version) bool { + lessThan := v.LessThanMajorMinor(v1) + if lessThan { + return true + } + + if v.Minor == v1.Minor { + if v.Bugfix < v1.Bugfix { + return true + } + } + + return false +} + +// LessThanMajorMinor returns true if v is smaller or equal to v1 based on the major and minor version. The bugfix version and meta part are not taken into account. +// minor numbers are compared in order. The and bugfix version and meta part is not taken into account. +func (v *Version) LessThanMajorMinor(v1 *Version) bool { if v.Major < v1.Major { return true } else if v.Major == v1.Major { if v.Minor < v1.Minor { return true - } else if v.Minor == v1.Minor { - if v.Bugfix < v1.Bugfix { - return true - } } } return false diff --git a/libbeat/common/version_test.go b/libbeat/common/version_test.go index 1a94569a596b..c7a6c60a8047 100644 --- a/libbeat/common/version_test.go +++ b/libbeat/common/version_test.go @@ -207,3 +207,52 @@ func TestVersionLessThan(t *testing.T) { assert.Equal(t, v.LessThan(v1), test.result, test.name) } } + +func TestVersionLessThanMajorMinor(t *testing.T) { + tests := []struct { + name string + version string + version1 string + result bool + }{ + { + name: "1.2.x < 2.0.x", + version: "1.2.3", + version1: "2.0.0", + result: true, + }, + { + name: "1.2.3 = 1.2.3-beta1", + version: "1.2.3", + version1: "1.2.3-beta1", + result: false, + }, + { + name: "5.4.x == 5.4.x", + version: "5.4.1", + version1: "5.4.2", + result: false, + }, + { + name: "5.5.x > 5.4.x", + version: "5.5.1", + version1: "5.4.2", + result: false, + }, + { + name: "6.1.x < 6.2.x", + version: "6.1.1-alpha3", + version1: "6.2.0", + result: true, + }, + } + + for _, test := range tests { + v, err := NewVersion(test.version) + assert.NoError(t, err) + v1, err := NewVersion(test.version1) + assert.NoError(t, err) + + assert.Equal(t, v.LessThanMajorMinor(v1), test.result, test.name) + } +}