Use _doc if ES major version is 7#9056
Conversation
ruflin
left a comment
There was a problem hiding this comment.
This needs a changelog entry.
ruflin
left a comment
There was a problem hiding this comment.
Left a few minor comments. Code LGTM. Could you make hound happy?
libbeat/common/version.go
Outdated
There was a problem hiding this comment.
Should this be called IsEmpty instead?
There was a problem hiding this comment.
Don't care about the name. stdlib seems to IsZero() bool for some types.
There was a problem hiding this comment.
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:
libbeat/dashboards/dashboards.go
Outdated
There was a problem hiding this comment.
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.
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.
I would rather remove it to reduce complexity in the code. Can also be done in a follow up PR to keep things smaller.
libbeat/template/template.go
Outdated
There was a problem hiding this comment.
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.
ruflin
left a comment
There was a problem hiding this comment.
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 { |
| 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.
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.