Skip to content
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

[ML] Resurrect _xpack/ml routes #77367

Merged
merged 4 commits into from
Sep 14, 2021

Conversation

droberts195
Copy link
Contributor

@droberts195 droberts195 commented Sep 7, 2021

Related to #51816 / #68905.

Adds back the _xpack/ml routes when using rest compatibility for a request.

Related to elastic#51816 / elastic#68905.

Adds back the _xpack/ml routes when using rest compatibility for a request.
@droberts195 droberts195 added the :ml Machine learning label Sep 7, 2021
@droberts195
Copy link
Contributor Author

This PR is closely modelled on #73977 - for consistency I've copied the approach from there, including the (near) duplication of spec files.

@droberts195 droberts195 marked this pull request as ready for review September 7, 2021 16:22
@elasticmachine elasticmachine added the Team:ML Meta label for the ML team label Sep 7, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

@benwtrent benwtrent self-requested a review September 7, 2021 16:54
Comment on lines +29 to +30
Route.builder(DELETE, BASE_PATH + "_delete_expired_data/{" + Job.ID + "}")
.replaces(DELETE, PRE_V7_BASE_PATH + "_delete_expired_data/{" + Job.ID + "}", RestApiVersion.V_7).build(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add the pre_v7 path here? It wasn't added. until 7.x

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you referring to @benwtrent ? The delete_expired_data action has existed as a REST api earlier than 7.x.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see what it is. Delete expired data can be called with or without a job ID. The option to call it with a job ID was added in 7.x and never had an _xpack fallback. So this is adding BWC in 8.x that didn't exist in 7.x.

However, the problem with enforcing the distinction is that it will cause considerable complication for the tests. At the moment the yamlRestCompatTest setup in 8.x just does a global replace of ml.delete_expired_data with xpack-ml.delete_expired_data. Enforcing the distinction would mean having more complicated test setup. Complexity costs money and I don't think it's worth it. If somebody does start using the newly added deprecated _xpack endpoint in 8.x instead of the correct one then it's likely because they're already using the _xpack everywhere else for ML, are using the REST compatibility layer, and know they have to do a sweep of their code at some point to switch to undeprecated endpoints. So we haven't really caused them any extra work. Anybody who already uses undeprecated endpoints is extremely unlikely to accidentally use a new deprecated _xpack endpoint.

So although pedantically one route should have the compatibility layer and one shouldn't, it's less work for us to just add them both and remove them both together.

Comment on lines +34 to +37
Route.builder(POST, BASE_PATH + "datafeeds/{" + DatafeedConfig.ID + "}/_preview")
.replaces(POST, PRE_V7_BASE_PATH + "datafeeds/{" + DatafeedConfig.ID + "}/_preview", RestApiVersion.V_7).build(),
Route.builder(POST, BASE_PATH + "datafeeds/_preview")
.replaces(POST, PRE_V7_BASE_PATH + "datafeeds/_preview", RestApiVersion.V_7).build()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These POST URLs were not added until 7.x. Should we have BWC with pre V7?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same problem as above. Having some versions of the endpoint support the REST compatibility layer but not others massively complicates the test setup.

"in a future major version it will be compulsory to use a datafeed", RestApiVersion.V_8
).build()
Route.builder(POST, BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/_data").deprecated(msg, RestApiVersion.V_8).build(),
Route.builder(POST, PRE_V7_BASE_PATH + "anomaly_detectors/{" + Job.ID + "}/_data").deprecated(msg, RestApiVersion.V_7).build()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to do a replaces AND have the additional deprecation message? It seems we are losing that the _xpack URL is old.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's possible to have two deprecation messages for the same endpoint.

It would be possible to have the _ml one say datafeeds will be compulsory in the future and the _xpack one say use the _ml one instead.

But I thought that "don't use this at all" was a more important thing to say than "use something different", especially as the different thing will then tell you not to use it at all.

It's not possible to use just the post data endpoint - you have to use some other ML endpoints too. So users would get the warnings about using _xpack for those other endpoints and hopefully realise that they needed to stop using _xpack everywhere. Also, in 8.x the _xpack version only exists when the REST compatibility layer is used. Presumably the user will test what happens when they stop using the REST compatibility layer before they stop using it in production. So they'd find out that the _xpack version had disappeared at that point, and then it's a simple rename to get back to the deprecation message that the endpoint is going to be removed at some point.

Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@droberts195
Copy link
Contributor Author

@elasticmachine update branch

@droberts195
Copy link
Contributor Author

@elasticmachine update branch

@droberts195 droberts195 merged commit 9d9d897 into elastic:master Sep 14, 2021
@droberts195 droberts195 deleted the add_back_ml_xpack_endpoints branch September 14, 2021 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:ml Machine learning >non-issue Team:ML Meta label for the ML team v8.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants