-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use _doc if ES major version is 7 #9056
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a changelog entry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few minor comments. Code LGTM. Could you make hound happy?
@@ -69,6 +69,10 @@ func NewVersion(version string) (*Version, error) { | |||
return &v, nil | |||
} | |||
|
|||
func (v *Version) IsValid() bool { | |||
return v.version != "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be called IsEmpty instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't care about the name. stdlib seems to IsZero() bool
for some types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping IsValid cause of docstring:
IsValid returns true if the version object stores a successfully parsed version number.
The NewVersion constructor is no simple constructor, but actually a parser. Wonder why we parse ourselves. github.com/hashicorp/go-version is a pretty good and flexible versions package:
} | ||
|
||
if majorVersion < 6 { | ||
if esLoader.version.Major < 6 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to this PR but I wonder if we should remove support for this.
@jsoriano More related to your other PR with removing 5.x dashboards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can consider to keep this in libbeat in case some community beat still wants to try to keep support for 5.x.
If not, I can remove it in in #8927, along with the importViaES
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather remove it to reduce complexity in the code. Can also be done in a follow up PR to keep things smaller.
var mappingName string | ||
major := t.esVersion.Major | ||
switch { | ||
case major < 6: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should even allow to run Beats 7.0 against ES 5.x?
@ruflin This PR will be for 7.0 and 6.7 the least. I'd say we should remove ES 5.x support in 7.0 in a followup PR (will add item to 7.0 bc meta issue). |
@urso Are the failing tests related to the flaky ones? |
Some tests are still failing. Some code seems in to sneak in a type named |
Update the Elasticsearch output and template generator to set the type to _doc if Elasticsearch major version is 7.
- Use common version instead of strings + parsing over and over again. - Having the parsed version available earlier, we can now configure the default document type based on version ranges. - Use `_doc` if version is >= 7.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only issue is changelog nit.
marshaled, err = json.Marshal(content) | ||
assert.NoError(t, err) | ||
assert.Contains(t, string(marshaled), "beat.timezone") | ||
cases := map[string]struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much nicer 👍
@@ -105,8 +104,8 @@ func TestIngest(t *testing.T) { | |||
} | |||
|
|||
client := getTestingElasticsearch(t) | |||
if strings.HasPrefix(client.Connection.version, "2.") { | |||
t.Skip("Skipping tests as pipeline not available in 2.x releases") | |||
if client.Connection.version.Major < 5 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully we can clean up this code one day as we should not test anymore against 2.x I think in the future.
Update the Elasticsearch output and template generator to set the type to _doc if Elasticsearch major version is 7. Use common.Version throughout - Use common version instead of strings + parsing over and over again. - Having the parsed version available earlier, we can now configure the default document type based on version ranges. - Use `_doc` if version is >= 7.0. Introduce unit tests for version aware bulk encoding. (cherry picked from commit 41f87a4)
…rsion (elastic#9813) (elastic#9815) Partial backport of elastic#9056 — only the code changes related to changing the datatype of version fields/variables from `string` to `common.Version`. (cherry picked from commit dafb638)
Update the Elasticsearch output and template generator to set the type
to _doc if Elasticsearch major version is 7.