-
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
Replace deprecated _xpack endpoints #9656
Conversation
1c9ae30
to
bda5db4
Compare
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.
Will this break compatibility with older versions? I think we should support both paths at least during some versions.
Yes, you are correct. Given that ES is deprecating the old endpoints only starting with 7.0.0, things would break for a user that ran Beats 7.0.0 (with the changes in this PR) against an ES 6.7.0 node. I'm assuming this combination will be supported, following from https://www.elastic.co/support/matrix#matrix_compatibility. Now, if ES could perform the deprecation in 6.7.0 itself, then the changes in this PR would not cause a break. Note that the changes in this PR will go only into 7.0.0/ Do you agree with my assessment above? If so, should I ask on elastic/elasticsearch#35958 if they would be willing to perform the deprecations starting in 6.7.0 itself? |
@jsoriano Any thoughts about my last comment? |
@ycombinator oh sorry, I didn't see this comment. Yes, I guess that having both paths already in ES 6.7.0 can also be an option. |
@jsoriano Looks like the new X-Pack APIs used in this PR all exist in ES 6.7.0 already, so there should be no breakage if a user tried to use Beats 7.0.0 (with this PR's changes in it) against ES 6.7.0. |
f755cad
to
904b45f
Compare
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 want Beats 6.7 and ES 7.0 to work, but also Beats 7.0 and ES 6.7 to work correctly. In fact, it is recommended to update Elasticsearch first, but yet we're used to Beats users running against older ES versions.
The Connect
on the beats ES client fetches the Elasticsearch version. You can access the vesion via client.GetVersion()
I think. Maybe we can add some logic to take the version into account. E.g.
func apiCall(v *common.Version, api, path string) string {
if v.Major >= 7 || (v.Major == 6 && v.Minor == 7) {
return fmt.Sprintf("/_%v/%v", api, path)
}
return fmt.Sprintf("/_xpack/%v/%v", api, path)
}
and create the URL via:
client.Request("GET", apiCall(client.GetVersion(), "ml", "anomaly_detectors"), ...)
Or some ApiCall struct getting you the path by version:
var mlAnomalyCall = apiCall{"ml", "anomaly_detectors"}
...
client.Request("GET", mlAnonamlyCall.Path(client.GetVersion()), ...)
As _xpack
namespace is still available in 7.0 I'd rather fallback to use _xpack
if the version is unknown in the code (which is the behavior of the apiCall function).
WDYT?
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 want Beats 6.7 and ES 7.0 to work, but also Beats 7.0 and ES 6.7 to work correctly. In fact, it is recommended to update Elasticsearch first, but yet we're used to Beats users running against older ES versions.
The Connect
on the beats ES client fetches the Elasticsearch version. You can access the vesion via client.GetVersion()
I think. Maybe we can add some logic to take the version into account. E.g.
func apiCall(v *common.Version, api, path string) string {
if v.Major >= 7 || (v.Major == 6 && v.Minor == 7) {
return fmt.Sprintf("/_%v/%v", api, path)
}
return fmt.Sprintf("/_xpack/%v/%v", api, path)
}
and create the URL via:
client.Request("GET", apiCall(client.GetVersion(), "ml", "anomaly_detectors"), ...)
Or some ApiCall struct getting you the path by version:
var mlAnomalyCall = apiCall{"ml", "anomaly_detectors"}
...
client.Request("GET", mlAnonamlyCall.Path(client.GetVersion()), ...)
As _xpack
namespace is still available in 7.0 I'd rather fallback to use _xpack
if the version is unknown in the code (which is the behavior of the apiCall function).
WDYT?
I'd also prefer something like @urso proposal |
I'm not sure we need the conditional logic, but maybe I'm missing something.
Let's break this statement into two, but in reverse order:
|
Chatted with @urso off-PR. He explained to me that we want to be even more liberal in our compatibility story than what's documented in the support matrix. So I'm going to implement his version check proposal in this PR now. |
@ycombinator do you mind also updating functionbeat's licenser for this change? |
@ph if I'm following that code correctly, it is calling the |
9e6b4de
to
1fd11c0
Compare
jenkins, test this |
1 similar comment
jenkins, test this |
b090923
to
885b74b
Compare
jenkins, test this |
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.
LGTM. One minor question.
Potentially worth a changelog even though users should not be impacted?
We should add this to our manual testing checklist (if we already have one). I didn't test it locally.
@@ -33,7 +33,7 @@ func init() { | |||
} | |||
|
|||
const ( | |||
jobPath = "/_xpack/ml/anomaly_detectors/_all/_stats" | |||
jobPathSuffix = "/anomaly_detectors/_all/_stats" |
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 has no ml prefix anymore?
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.
In 7.0.0+, the preferred path is _ml/anomaly_detectors/_all/_stats
(notice the underscore in _ml
). Before that version, the path is _xpack/ml/anomaly_detectors/_all/_stats
(notice that ml
does not contain the underscore).
Given this difference I decided to only store the suffix, anomaly_detectors/_all/_stats
, in the variable here. Further below I concatenate either /_ml
or _xpack/ml
to the suffix, depending on the ES version we're talking to.
885b74b
to
d068660
Compare
I think the question was about the ML prefix? If so, I've answered it in the comment thread.
If a user runs a Beat < 7.0.0 with ES >= 7.0.0, they will see deprecation logs in their Elasticsearch logs for Elasticsearch X-Pack API calls made from their Beat. So I added a CHANGELOG entry that says that they won't see such calls with this PR 😄.
++ where is this checklist kept? I can add this item to it. |
jenkins, test this |
For the list, not sure if it exists yet. |
In 7.0.0, Elasticsearch is deprecating most
_xpack/*
endpoints. See elastic/elasticsearch#35958.This PR updates the Beats codebase, except test fixtures, with the appropriate replacements for the deprecated endpoints.