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

[Deprecations service] make correctiveActions.manualSteps required #100997

Merged
merged 13 commits into from
Jun 2, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ correctiveActions: {
[key: string]: any;
};
};
manualSteps?: string[];
manualSteps: string[];
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface DeprecationsDetails

| Property | Type | Description |
| --- | --- | --- |
| [correctiveActions](./kibana-plugin-core-server.deprecationsdetails.correctiveactions.md) | <code>{</code><br/><code> api?: {</code><br/><code> path: string;</code><br/><code> method: 'POST' &#124; 'PUT';</code><br/><code> body?: {</code><br/><code> [key: string]: any;</code><br/><code> };</code><br/><code> };</code><br/><code> manualSteps?: string[];</code><br/><code> }</code> | |
| [correctiveActions](./kibana-plugin-core-server.deprecationsdetails.correctiveactions.md) | <code>{</code><br/><code> api?: {</code><br/><code> path: string;</code><br/><code> method: 'POST' &#124; 'PUT';</code><br/><code> body?: {</code><br/><code> [key: string]: any;</code><br/><code> };</code><br/><code> };</code><br/><code> manualSteps: string[];</code><br/><code> }</code> | |
| [deprecationType](./kibana-plugin-core-server.deprecationsdetails.deprecationtype.md) | <code>'config' &#124; 'feature'</code> | (optional) Used to identify between different deprecation types. Example use case: in Upgrade Assistant, we may want to allow the user to sort by deprecation type or show each type in a separate tab.<!-- -->Feel free to add new types if necessary. Predefined types are necessary to reduce having similar definitions with different keywords across kibana deprecations. |
| [documentationUrl](./kibana-plugin-core-server.deprecationsdetails.documentationurl.md) | <code>string</code> | |
| [level](./kibana-plugin-core-server.deprecationsdetails.level.md) | <code>'warning' &#124; 'critical' &#124; 'fetch_error'</code> | levels: - warning: will not break deployment upon upgrade - critical: needs to be addressed before upgrade. - fetch\_error: Deprecations service failed to grab the deprecation details for the domain. |
Expand Down
38 changes: 32 additions & 6 deletions packages/kbn-config/src/config_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,14 @@ test('logs deprecation warning during validation', async () => {
const configService = new ConfigService(rawConfig, defaultEnv, logger);
mockApplyDeprecations.mockImplementationOnce((config, deprecations, createAddDeprecation) => {
const addDeprecation = createAddDeprecation!('');
addDeprecation({ message: 'some deprecation message' });
addDeprecation({ message: 'another deprecation message' });
addDeprecation({
message: 'some deprecation message',
correctiveActions: { manualSteps: ['do X'] },
});
addDeprecation({
message: 'another deprecation message',
correctiveActions: { manualSteps: ['do Y'] },
});
return { config, changedPaths: mockedChangedPaths };
});

Expand All @@ -444,13 +450,24 @@ test('does not log warnings for silent deprecations during validation', async ()
mockApplyDeprecations
.mockImplementationOnce((config, deprecations, createAddDeprecation) => {
const addDeprecation = createAddDeprecation!('');
addDeprecation({ message: 'some deprecation message', silent: true });
addDeprecation({ message: 'another deprecation message' });
addDeprecation({
message: 'some deprecation message',
correctiveActions: { manualSteps: ['do X'] },
silent: true,
});
addDeprecation({
message: 'another deprecation message',
correctiveActions: { manualSteps: ['do Y'] },
});
return { config, changedPaths: mockedChangedPaths };
})
.mockImplementationOnce((config, deprecations, createAddDeprecation) => {
const addDeprecation = createAddDeprecation!('');
addDeprecation({ message: 'I am silent', silent: true });
addDeprecation({
message: 'I am silent',
silent: true,
correctiveActions: { manualSteps: ['do Z'] },
});
return { config, changedPaths: mockedChangedPaths };
});

Expand Down Expand Up @@ -519,7 +536,11 @@ describe('getHandledDeprecatedConfigs', () => {
mockApplyDeprecations.mockImplementationOnce((config, deprecations, createAddDeprecation) => {
deprecations.forEach((deprecation) => {
const addDeprecation = createAddDeprecation!(deprecation.path);
addDeprecation({ message: `some deprecation message`, documentationUrl: 'some-url' });
addDeprecation({
message: `some deprecation message`,
documentationUrl: 'some-url',
correctiveActions: { manualSteps: ['do X'] },
});
});
return { config, changedPaths: mockedChangedPaths };
});
Expand All @@ -532,6 +553,11 @@ describe('getHandledDeprecatedConfigs', () => {
"base",
Array [
Object {
"correctiveActions": Object {
"manualSteps": Array [
"do X",
],
},
"documentationUrl": "some-url",
"message": "some deprecation message",
},
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-config/src/deprecation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export interface DeprecatedConfigDetails {
silent?: boolean;
/* (optional) link to the documentation for more details on the deprecation. */
documentationUrl?: string;
/* (optional) corrective action needed to fix this deprecation. */
correctiveActions?: {
/* corrective action needed to fix this deprecation. */
correctiveActions: {
/**
* Specify a list of manual steps our users need to follow
* to fix the deprecation before upgrade.
Expand Down
11 changes: 9 additions & 2 deletions src/core/public/deprecations/deprecations_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ describe('DeprecationsClient', () => {
path: 'some-path',
method: 'POST',
},
manualSteps: ['manual-step'],
},
};

Expand All @@ -104,7 +105,9 @@ describe('DeprecationsClient', () => {
domainId: 'testPluginId-1',
message: 'some-message',
level: 'warning',
correctiveActions: {},
correctiveActions: {
manualSteps: ['manual-step'],
},
};

const isResolvable = deprecationsClient.isDeprecationResolvable(mockDeprecationDetails);
Expand All @@ -120,7 +123,9 @@ describe('DeprecationsClient', () => {
domainId: 'testPluginId-1',
message: 'some-message',
level: 'warning',
correctiveActions: {},
correctiveActions: {
manualSteps: ['manual-step'],
},
};
const result = await deprecationsClient.resolveDeprecation(mockDeprecationDetails);

Expand All @@ -144,6 +149,7 @@ describe('DeprecationsClient', () => {
extra_param: 123,
},
},
manualSteps: ['manual-step'],
},
};
const result = await deprecationsClient.resolveDeprecation(mockDeprecationDetails);
Expand Down Expand Up @@ -176,6 +182,7 @@ describe('DeprecationsClient', () => {
extra_param: 123,
},
},
manualSteps: ['manual-step'],
},
};
http.fetch.mockRejectedValue({ body: { message: mockResponse } });
Expand Down
6 changes: 3 additions & 3 deletions src/core/server/config/deprecation/core_deprecations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('core deprecations', () => {
const { messages } = applyCoreDeprecations();
expect(messages).toMatchInlineSnapshot(`
Array [
"Environment variable CONFIG_PATH is deprecated. It has been replaced with KBN_PATH_CONF pointing to a config folder",
"Environment variable \\"CONFIG_PATH\\" is deprecated. It has been replaced with \\"KBN_PATH_CONF\\" pointing to a config folder",
]
`);
});
Expand Down Expand Up @@ -405,7 +405,7 @@ describe('core deprecations', () => {
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.events.log\\" has been deprecated and will be removed in 8.0. Moving forward, log levels can be customized on a per-logger basis using the new logging configuration. ",
"\\"logging.events.log\\" has been deprecated and will be removed in 8.0. Moving forward, log levels can be customized on a per-logger basis using the new logging configuration.",
]
`);
});
Expand All @@ -418,7 +418,7 @@ describe('core deprecations', () => {
});
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"logging.events.error\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level: error\\" in your logging configuration. ",
"\\"logging.events.error\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level: error\\" in your logging configuration.",
]
`);
});
Expand Down
Loading