-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Api Deprecations #193668
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
Closed
Closed
Api Deprecations #193668
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0d18ace
delete old README
jloleysens ede49dd
added deprecation description to router, v1
jloleysens 59e896b
added enhanced deprecations to versioned router
jloleysens 48fa2a1
oh boy
jloleysens 66264ae
limit types of interfaces
jloleysens 502d66f
wip idea
jloleysens 37c3361
wip idea 2
jloleysens 3f8abb8
clean up types
jloleysens 8dc9aad
wip 3
jloleysens 27131ad
wip 4
jloleysens c46e885
Merge branch 'main' of github.com:elastic/kibana into api-deprecations
Bamieh adb25ae
progress so far
Bamieh 5de5824
lets take a look
Bamieh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
packages/core/deprecations/core-deprecations-server-internal/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,90 @@ | ||
| # @kbn/core-deprecations-server-internal | ||
|
|
||
| This package contains the internal types and implementation of Core's server-side `deprecations` service. | ||
|
|
||
|
|
||
| /** Router: | ||
| * register Usage counters side core setup | ||
| * DOMIANID: CORE.ROUTER | ||
| * At router definition | ||
| * Call deprecations.registerDeprecation | ||
| * - group all renamed etc | ||
|
|
||
| * GroupId: Method / path | ||
| * when route is called | ||
| if deprecation is triggered based on rename/ path/ remove | ||
| - increment counter: GroupId, domainId, type: 'count' | ||
|
|
||
|
|
||
| set: ['body.a'], | ||
| unset: ['body.a'], | ||
|
|
||
| { | ||
| "deprecations": [ | ||
| { | ||
| "configPath": "xpack.reporting.roles.enabled", | ||
| "title": "The \"xpack.reporting.roles\" setting is deprecated", | ||
| "level": "warning", | ||
| "message": "The default mechanism for Reporting privileges will work differently in future versions, which will affect the behavior of this cluster. Set \"xpack.reporting.roles.enabled\" to \"false\" to adopt the future behavior before upgrading.", | ||
| "correctiveActions": { | ||
| "manualSteps": [ | ||
| "Set \"xpack.reporting.roles.enabled\" to \"false\" in kibana.yml.", | ||
| "Remove \"xpack.reporting.roles.allow\" in kibana.yml, if present.", | ||
| "Go to Management > Security > Roles to create one or more roles that grant the Kibana application privilege for Reporting.", | ||
| "Grant Reporting privileges to users by assigning one of the new roles." | ||
| ], | ||
| api: { | ||
| path: 'some-path', | ||
| method: 'POST', | ||
| body: { | ||
| extra_param: 123, | ||
| }, | ||
| }, | ||
| }, | ||
| "deprecationType": "config", | ||
| "requireRestart": true, | ||
| "domainId": "xpack.reporting" | ||
| } | ||
| ] | ||
| } | ||
|
|
||
|
|
||
| domainId: 'routesDeprecations' | ||
| counterName: '{RouteAPIGroupingID}', | ||
| counterType: 'count', | ||
|
|
||
| RouteAPIGroupingID | ||
| If Route level: method, route | ||
|
|
||
| For fixed: | ||
| counterType: 'count:fixed', | ||
|
|
||
| We count all deprecations | ||
|
|
||
| { | ||
| 'RouteAPIGroupingID': { | ||
| message: '', | ||
| deprecationDetails | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Approach 1: | ||
| In memory: | ||
| 1. Store in memory the deprecation details defined at routes setup | ||
|
|
||
| 3. enrich some text (last called etc) filter out diff 0 | ||
| 4. send result | ||
|
|
||
| SO and get rid of Usage counter | ||
|
|
||
| interface UsageCountersParams { | ||
| /** The domainId used to create the Counter API */ | ||
| domainId: string; | ||
| /** The name of the counter. Optional, will return all counters in the same domainId that match the rest of filters if omitted */ | ||
| counterName?: string; | ||
| /** The 2. on UA api call we do matching between usage counters and the deprecation details in memorytype of counter. Optional, will return all counters in the same domainId that match the rest of filters if omitted */ | ||
| counterType?: string; | ||
| /** Namespace of the counter. Optional, counters of the 'default' namespace will be returned if omitted */ | ||
| namespace?: string; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
...ges/core/deprecations/core-deprecations-server-internal/src/register_core_deprecations.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import type { IConfigService } from '@kbn/config'; | ||
| import type { Logger } from '@kbn/logging'; | ||
| import { InternalHttpServiceSetup } from '@kbn/core-http-server-internal'; | ||
| import { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; | ||
| import { DeprecationsFactory } from './deprecations_factory'; | ||
|
|
||
| interface RegisterConfigDeprecationsInfo { | ||
| deprecationsFactory: DeprecationsFactory; | ||
| configService: IConfigService; | ||
| } | ||
|
|
||
| export const registerConfigDeprecationsInfo = ({ | ||
| deprecationsFactory, | ||
| configService, | ||
| }: RegisterConfigDeprecationsInfo) => { | ||
| const handledDeprecatedConfigs = configService.getHandledDeprecatedConfigs(); | ||
|
|
||
| for (const [domainId, deprecationsContexts] of handledDeprecatedConfigs) { | ||
| const deprecationsRegistry = deprecationsFactory.getRegistry(domainId); | ||
| deprecationsRegistry.registerDeprecations({ | ||
| getDeprecations: () => { | ||
| return deprecationsContexts.map( | ||
| ({ | ||
| configPath, | ||
| title = `${domainId} has a deprecated setting`, | ||
| level, | ||
| message, | ||
| correctiveActions, | ||
| documentationUrl, | ||
| }) => ({ | ||
| configPath, | ||
| title, | ||
| level, | ||
| message, | ||
| correctiveActions, | ||
| documentationUrl, | ||
| deprecationType: 'config', | ||
| requireRestart: true, | ||
| }) | ||
| ); | ||
| }, | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| export interface ApiDeprecationsServiceDeps { | ||
| logger: Logger; | ||
| deprecationsFactory: DeprecationsFactory; | ||
| http: InternalHttpServiceSetup; | ||
| coreUsageData: InternalCoreUsageDataSetup; | ||
| } | ||
|
|
||
| export const registerApiDeprecationsInfo = ({ | ||
| deprecationsFactory, | ||
| http, | ||
| coreUsageData, | ||
| }: ApiDeprecationsServiceDeps): void => { | ||
| const deprecationsRegistery = deprecationsFactory.getRegistry('core.api_deprecations'); | ||
|
|
||
| deprecationsRegistery.registerDeprecations({ | ||
| getDeprecations: async () => { | ||
| console.log('calling get!!'); | ||
|
|
||
| const usageClient = coreUsageData.getClient(); | ||
| const deprecatedRoutes = http.getDeprecatedRoutes(); | ||
| const deprecatedStats = await usageClient.getDeprecatedApisStats(); | ||
|
|
||
| console.log('deprecatedRoutes::', deprecatedRoutes); | ||
| console.log('deprecatedStats::', deprecatedStats); | ||
|
|
||
| // Do the matching here | ||
| // Do the diff here | ||
| // write the messages here | ||
|
|
||
| return [ | ||
| { | ||
| routePath: '/api/chocolate_love', | ||
| routeMethod: 'GET', | ||
| title: `The Route "[GET] /api/chocolate_love" has deprected params`, | ||
| level: 'warning', | ||
| message: `Deprecated route [GET] /api/chocolate_love was called 34 times with deprecated params.\n | ||
| The last time the deprecation was triggered was on Fri Sep 20 2024 14:28:22.\n | ||
| This deprecation was previously marked as resolved but was called 3 times since it was marked on Fri Sep 13 2024 10:28:22.`, | ||
| documentationUrl: 'https://google.com', | ||
| correctiveActions: { | ||
| manualSteps: [ | ||
| 'The following query params are deprecated: dont_use,my_old_query_param', | ||
| 'Make sure you are not using any of these parameters when calling the API', | ||
| ], | ||
| api: { | ||
| path: 'some-path', | ||
| method: 'POST', | ||
| body: { | ||
| extra_param: 123, | ||
| }, | ||
| }, | ||
| }, | ||
| deprecationType: 'api', | ||
| requireRestart: false, | ||
| domainId: 'core.router', | ||
| }, | ||
| ]; | ||
| }, | ||
| }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.