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

API Deprecations replace deprecated: true with the deprecated object #196095

Open
Bamieh opened this issue Oct 14, 2024 · 5 comments
Open

API Deprecations replace deprecated: true with the deprecated object #196095

Bamieh opened this issue Oct 14, 2024 · 5 comments
Assignees
Labels
NeededFor:Core Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)

Comments

@Bamieh
Copy link
Member

Bamieh commented Oct 14, 2024

The following routes have deprecated: true. We need to replace them with the deprecated object that provides enough metadata for users in UA to be able to address it before their next upgrade.
We will start throwing an error in the near future to prevent developers from passing true to the deprecated param so we need to address those ASAP.

Here is an example of what true needs to be replaced with (note the options.deprecated param):

  router.versioned
    .get({
      path: '/',
      access: 'public',
      enableQueryVersion: true,
    })
    .addVersion(
      {
        validate: false,
        version: '2023-10-31',
        options: {
          deprecated: {
            documentationLink: 'https://www.elastic.co/guide/en/kibana/current/api.html',
            severity: 'warning',
            reason: {
              type: 'bump',
              newApiVersion: '2024-10-13',
            },
          },
        },
      },

See these instructions on adding a guide and this example PR, guides are required for each deprecation!
Check the PR notes or docs to learn more #196081

Saved objects APIs

/api/saved_objects/{type}/{id}
/api/saved_objects/resolve/{type}/{id}
/api/saved_objects/{type}/{id?}
/api/saved_objects/{type}/{id}
/api/saved_objects/_find
/api/saved_objects/{type}/{id}
/api/saved_objects/_bulk_get
/api/saved_objects/_bulk_create
/api/saved_objects/_bulk_resolve
/api/saved_objects/_bulk_update
/api/saved_objects/_bulk_delete

Actions APIs

/api/actions/action
/api/actions/action/{id}
/api/actions/action/{id}
/api/actions
/api/actions/action/{id}
/api/actions/list_action_types
/api/actions/action/{id}/_execute

Alerts APIs

/api/alerts/alert/{id?}
/api/alerts/alert/{id}
/api/alerts/_find
/api/alerts/alert/{id}
/api/alerts/alert/{id}/state
/api/alerts/alert/{id}/_instance_summary
/api/alerts/list_alert_types
/api/alerts/alert/{id}
/api/alerts/alert/{id}/_enable
/api/alerts/alert/{id}/_disable
/api/alerts/alert/{id}/_update_api_key
/api/alerts/alert/{id}/_mute_all
/api/alerts/alert/{id}/_unmute_all
/api/alerts/alert/{alert_id}/alert_instance/{alert_instance_id}/_mute
/api/alerts/alert/{alertId}/alert_instance/{alertInstanceId}/_unmute
/api/alerts/_health

Cases APIs

/api/cases/{case_id}/user_actions
/api/cases/status
/api/cases/{case_id}/comments
@Bamieh Bamieh self-assigned this Oct 14, 2024
@botelastic botelastic bot added the needs-team Issues missing a team label label Oct 14, 2024
@jloleysens
Copy link
Contributor

Saved objects APIs

While it's true these are deprecated, bc we decided to slow down removal we might need to hold off surfacing this in the UA until viable alternatives are ready for main use cases.

@TinaHeiligers
Copy link
Contributor

TinaHeiligers commented Oct 15, 2024

Saved objects APIs

While it's true these are deprecated, bc we decided to slow down removal we might need to hold off surfacing this in the UA until viable alternatives are ready for main use cases.

I'd prefer to surface these now and continue to do so throughout v9 because they're widely used.

router[versioned?].get(
    {
      path: '/',
      options: {
        deprecated: {
           documentationUrl: 'https://www.elastic.co/guide/en/kibana/current/api.html',
           severity: 'warning',
           reason: {
              type: 'remove',
            },
        },
      },
    },
    async (context, req, res) => {

While it's true we don't have alternatives for all SO types (and probably never will), there are some and the docs point users to those: https://www.elastic.co/guide/en/kibana/current/api.html.

The other reason we should make a noise now is that we've been trying to get rid of the SO APIs for 4+ years and the deprecation of these specific APIs is generally ignored.

@TinaHeiligers TinaHeiligers added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Oct 15, 2024
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@TinaHeiligers
Copy link
Contributor

For the record, Core decided not to surface the deprecated global saved objects HTTP APIs in the upgrade assistant as critical warnings, since they are not being removed in 9.0.

Bamieh added a commit that referenced this issue Oct 22, 2024
# Summary

Adds a new API deprecations feature inside core.
This feature enabled plugin developers to mark their versioned and
unversioned public routes as deprecated.
These deprecations will be surfaced to the users through UA to help them
understand the deprecation and address it before upgrading. This PR also
surfaces these deprecations to UA.

Closes #117241

1. Core service to flag deprecated routes
2. UA code to surface and resolve deprecated routes

## Flagging a deprecated Route

### The route deprecation option
We have three types of route deprecations:

- `type: bump`: A version bump deprecation means the API has a new
version and the current version will be removed in the future in favor
of the newer version.
- `type: remove`: This API will be completely removed. You will no
longer be able to use it in the future.
- `type: migrate`: This API will be migrated to a different API and will
be removed in the future in favor of the other API.


All route deprecations expect a documentation link to help users
navigate. We might add a generic documentation link and drop this
requirement in the future but for now this is required.

### Deprecated Route Example
Full examples can be found in the `routing_example` example plugin
located in this directory:
`examples/routing_example/server/routes/deprecated_routes`

```ts
router[versioned?].get(
    {
      path: '/',
      options: {
        deprecated: {
           documentationUrl: 'https://google.com',
           severity: 'warning',
           reason: {
              type: 'bump',
              newApiVersion: '2024-10-13',
            },
        },
      },
    },
    async (context, req, res) => {
...
```

## Surfaced API deprecations in UA

The list of deprecated APIs will be listed inside Kibana deprecations
along with the already supported config deprecations.
<img width="1728" alt="image"
src="https://github.com/user-attachments/assets/5bece704-b80b-4397-8ba2-6235f8995e4a">


Users can click on the list item to learn more about each deprecation
and mark it as resolved
<img width="1476" alt="image"
src="https://github.com/user-attachments/assets/91c9207b-b246-482d-a5e4-21d0c61582a8">



### Marking as resolved
Users can click on mark as resolved button in the UA to hide the
deprecation from the Kiban deprecations list.
We keep track on when this button was clicked and how many times the API
has been called. If the API is called again the deprecation will
re-appear inside the list. We might add a feature in the future to
permenantly supress the API deprecation from showing in the list through
a configuration (#196089)

If the API has been marked as resolved before we show this in the flyout
message:
> The API GET /api/deprecations/ has been called 25 times. The last time
the API was called was on Monday, October 14, 2024 1:08 PM +03:00.
> The api has been called 2 times since the last time it was marked as
resolved on Monday, October 14, 2024 1:08 PM +03:00


Once marked as resolved the flyout exists and we show this to the user
until they refresh the page
<img width="1453" alt="image"
src="https://github.com/user-attachments/assets/8bb5bc8b-d1a3-478f-9489-23cfa7db6350">


## Telemetry:
We keep track of 2 new things for telemetry purposes:
1. The number of times the deprecated API has been called
2. The number of times the deprecated API has been resolved (how many
times the mark as resolved button in UA was clicked)

## Code review
- [x] Core team is expected to review the whole PR
- [ ] Docs team to review the copy and update the UA displayed texts
(title, description, and manual steps)
- [x] kibana-management team is expected to review the UA code changes
and UI
- [ ] A few teams are only required to approve this PR and update their
`deprecated: true` route param to the new deprecationInfo object we now
expect. There is an issue tracker to address those in separate PRs later
on: #196095

## Testing

Run kibana locally with the test example plugin that has deprecated
routes
```
yarn start --plugin-path=examples/routing_example --plugin-path=examples/developer_examples
```

The following comprehensive deprecated routes examples are registered
inside the folder:
`examples/routing_example/server/routes/deprecated_routes`

Run them in the console to trigger the deprecation condition so they
show up in the UA:

```
# Versioned routes: Version 1 is deprecated
GET kbn:/api/routing_example/d/versioned?apiVersion=1
GET kbn:/api/routing_example/d/versioned?apiVersion=2

# Non-versioned routes
GET kbn:/api/routing_example/d/removed_route
POST kbn:/api/routing_example/d/migrated_route
{}
```

1. You can also mark as deprecated in the UA to remove the deprecation
from the list.
2. Check the telemetry response to see the reported data about the
deprecated route.
3. Calling version 2 of the API does not do anything since it is not
deprecated unlike version `1` (`GET
kbn:/api/routing_example/d/versioned?apiVersion=2`)
4. Internally you can see the deprecations counters from the dev console
by running the following:
```
GET .kibana_usage_counters/_search
{
    "query": {
        "bool": {
            "should": [
              {"match": { "usage-counter.counterType": "deprecated_api_call:total"}},
              {"match": { "usage-counter.counterType": "deprecated_api_call:resolved"}},
              {"match": { "usage-counter.counterType": "deprecated_api_call:marked_as_resolved"}}
            ]
        }
    }
}

```

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: florent-leborgne <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeededFor:Core Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)
Projects
None yet
Development

No branches or pull requests

4 participants