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

[Cases] Deprecate endpoints #124773

Merged
merged 18 commits into from
Feb 11, 2022
Merged

[Cases] Deprecate endpoints #124773

merged 18 commits into from
Feb 11, 2022

Conversation

cnasikas
Copy link
Member

@cnasikas cnasikas commented Feb 6, 2022

Summary

This PR deprecates the following Cases endpoints:

It follows the recommendations specified in: #105692

Checklist

Delete any items that are not applicable to this PR.

For maintainers

Release notes

The following Cases API endpoints are deprecated:

The includeComments query parameter of the GET /api/cases/{case_id} endpoint is deprecated.

@cnasikas cnasikas self-assigned this Feb 6, 2022
@cnasikas cnasikas added Feature:Cases Cases feature Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.1.0 v8.2.0 labels Feb 6, 2022
@cnasikas cnasikas marked this pull request as ready for review February 7, 2022 11:27
@cnasikas cnasikas requested a review from a team as a code owner February 7, 2022 11:27
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops-cases (Feature:Cases)

@cnasikas cnasikas added release_note:deprecation release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. labels Feb 7, 2022
@cnasikas cnasikas requested a review from kobelb February 7, 2022 15:49
@cnasikas cnasikas force-pushed the deprecate_endpoints branch from c7b55e7 to 4ea4cee Compare February 7, 2022 15:54
@cnasikas cnasikas force-pushed the deprecate_endpoints branch from 4ea4cee to d4d8fe2 Compare February 7, 2022 15:55
@@ -30,6 +33,9 @@ export function initGetCaseApi({ router, logger }: RouteDeps) {
const id = request.params.case_id;

return response.ok({
headers: {
Copy link
Member

Choose a reason for hiding this comment

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

It looks like the warning header will be returned on every call to this endpoint - but don't you just want the header if they use the query.includeComments property?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, good point! I will update accordingly.

Copy link
Member Author

@cnasikas cnasikas Feb 8, 2022

Choose a reason for hiding this comment

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

@pmuellr I just noticed that we default it to true if the user omits it so I don't think we can distinguish if the user provided the parameter or not.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, bummer.

You could change the type to boolean | undefined, and then apply the default outside of the validation, but that's clumsy, and changes your typing which could require more undefined checks. Perhaps instead, since false is the "deprecated" version, you can just check after the validation if it's false and then add the header? So it wouldn't be marked deprecated if they used the param and it was true.

Another possibility would be to see if there's a way to get the parameters in more of a "raw" state, after the validation, from the request. And then put the check there.

I really don't think we want this header used every time the API is used.

Copy link
Member Author

Choose a reason for hiding this comment

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

@pmuellr Amazing idea about the "raw" state. I pushed the changes you suggested.

@@ -27,10 +30,15 @@ export function initGetAllCaseUserActionsApi({ router, logger }: RouteDeps) {
return response.badRequest({ body: 'RouteHandlerContext is not registered for cases' });
}

logger.warn(`The get all cases user actions API '${CASE_USER_ACTIONS_URL}' is deprecated.`);
Copy link
Member Author

Choose a reason for hiding this comment

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

@lukeelmers @kobelb Cases are gonna use these endpoints until we provide alternatives. Is it ok if we log warnings even when Cases are using them?

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't wanna use logger.warn for deprecations. "warn" is a high logging level that should be used when things are going seriously awry.

@elastic/kibana-core: did core end up exposing a logger that we should be using for intermittent deprecation usage, for example when a client is calling a HTTP API in a deprecated manner?

Copy link
Member

Choose a reason for hiding this comment

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

did core end up exposing a logger that we should be using for intermittent deprecation usage

@kobelb Unfortunately we do not have something like this. There are a few other places in Kibana I am aware of (specifically in Core & Security) where we are logging deprecations for routes at a warn level.

We have other work we want to do in this area to improve the deprecation process for HTTP APIs:

But to my knowledge we do not have an issue for what you're specifically mentioning here (that is, a dedicated logger exposed to http routes for logging deprecations specifically).

Cases are gonna use these endpoints until we provide alternatives. Is it ok if we log warnings even when Cases are using them?

My main concern would be if we are logging deprecation warnings when users aren't initiating the calls to the deprecated API. I would recommend either adding some logic to try to differentiate between Kibana & non-Kibana requests, or perhaps creating a duplicate route that's just for use by Cases, and simply don't log deprecations from that route.

If you want to attempt to differentiate between Kibana & non-Kibana requests & conditionally log based on that info, there is some prior art in the spaces plugin: https://github.com/elastic/kibana/blob/ec30f2aeeb10fb64b507935e558832d3ef5abfaa/x-pack/plugins/spaces/server/usage_stats/usage_stats_client.ts#L113-L118

This is an imperfect workaround, but will address the majority of situations.

Copy link
Member

Choose a reason for hiding this comment

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

Just dropping by to add another related issue: #112291

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you @lukeelmers! I will go with adding some logic to differentiate between Kibana & non-Kibana requests. We plan to introduce different endpoints as alternatives in the future so I will switch Cases to them when the time comes. Thanks!

Copy link
Contributor

@kobelb kobelb Feb 10, 2022

Choose a reason for hiding this comment

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

If there's precedent for using the warn level for this and we haven't had customers complain, feel free to follow suit @cnasikas.

I do agree that we shouldn't be logging these deprecations for internal HTTP requests. One other option we could explore is having /api public routes and /internal internal routes, and not doing the deprecation logging for the internal routes.

@cnasikas
Copy link
Member Author

cnasikas commented Feb 9, 2022

@elasticmachine merge upstream

Copy link
Contributor

@kobelb kobelb left a comment

Choose a reason for hiding this comment

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

If we don't have a way to log these deprecations at the moment, we can proceed with the current PR that includes with the Warning response header and add logging in a subsequent PR. I don't see any other Kibana HTTP endpoints including the warning response header, but what you have looks fine by me.

@@ -27,10 +30,15 @@ export function initGetAllCaseUserActionsApi({ router, logger }: RouteDeps) {
return response.badRequest({ body: 'RouteHandlerContext is not registered for cases' });
}

logger.warn(`The get all cases user actions API '${CASE_USER_ACTIONS_URL}' is deprecated.`);
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't wanna use logger.warn for deprecations. "warn" is a high logging level that should be used when things are going seriously awry.

@elastic/kibana-core: did core end up exposing a logger that we should be using for intermittent deprecation usage, for example when a client is calling a HTTP API in a deprecated manner?

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

Changes to the route deprecation LGTM

I don't see any other Kibana HTTP endpoints including the warning response header, but what you have looks fine by me.

I missed this comment earlier, but this is correct -- AFAIK there are no other places where we are manually implementing a Warning header. This implementation seems fine, however once we are able to address #105692, it will be good to come back and change this implementation to be consistent with our long-term solution.

@cnasikas
Copy link
Member Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @cnasikas

@cnasikas
Copy link
Member Author

Changes to the route deprecation LGTM

I don't see any other Kibana HTTP endpoints including the warning response header, but what you have looks fine by me.

I missed this comment earlier, but this is correct -- AFAIK there are no other places where we are manually implementing a Warning header. This implementation seems fine, however once we are able to address #105692, it will be good to come back and change this implementation to be consistent with our long-term solution.

Thank you @lukeelmers! Yes, when core supports it we will come back and change it.

@cnasikas cnasikas merged commit eb7591b into elastic:main Feb 11, 2022
@cnasikas cnasikas deleted the deprecate_endpoints branch February 11, 2022 12:03
@cnasikas cnasikas added the auto-backport Deprecated - use backport:version if exact versions are needed label Feb 11, 2022
@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.1 Backport failed because of merge conflicts

How to fix

Re-run the backport manually:

node scripts/backport --pr 124773

Questions ?

Please refer to the Backport tool documentation

cnasikas added a commit to cnasikas/kibana that referenced this pull request Feb 11, 2022
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit eb7591b)

# Conflicts:
#	x-pack/plugins/cases/server/routes/api/stats/get_status.ts
cnasikas added a commit that referenced this pull request Feb 11, 2022
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit eb7591b)

# Conflicts:
#	x-pack/plugins/cases/server/routes/api/stats/get_status.ts
@cnasikas cnasikas removed the release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. label Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:Cases Cases feature release_note:deprecation Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.1.0 v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants