From f2fc5fe3d6652f8be89ee0edd08ac00be13cb822 Mon Sep 17 00:00:00 2001 From: chrisronline Date: Thu, 23 Sep 2021 12:43:56 -0400 Subject: [PATCH 1/5] Track deprecated configs --- x-pack/plugins/actions/server/index.test.ts | 26 ++++++++++++++++++++- x-pack/plugins/actions/server/index.ts | 21 +++++++++++++++++ x-pack/plugins/task_manager/server/index.ts | 3 +++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/actions/server/index.test.ts b/x-pack/plugins/actions/server/index.test.ts index dbe8fca806f17..3493e3729a8ef 100644 --- a/x-pack/plugins/actions/server/index.test.ts +++ b/x-pack/plugins/actions/server/index.test.ts @@ -14,7 +14,7 @@ const applyStackAlertDeprecations = (settings: Record = {}) => const _config = { [CONFIG_PATH]: settings, }; - const { config: migrated } = applyDeprecations( + const { config: migrated, changedPaths } = applyDeprecations( _config, deprecations.map((deprecation) => ({ deprecation, @@ -27,6 +27,7 @@ const applyStackAlertDeprecations = (settings: Record = {}) => return { messages: deprecationMessages, migrated, + changedPaths, }; }; @@ -40,5 +41,28 @@ describe('index', () => { ] `); }); + + it('should properly unset deprecated configs', () => { + const { messages, changedPaths } = applyStackAlertDeprecations({ + customHostSettings: [{ ssl: { rejectUnauthorized: true } }], + rejectUnauthorized: true, + proxyRejectUnauthorizedCertificates: true, + }); + expect(changedPaths.unset).toStrictEqual([ + 'xpack.actions.customHostSettings.ssl.rejectUnauthorized', + 'xpack.actions.rejectUnauthorized', + 'xpack.actions.proxyRejectUnauthorizedCertificates', + ]); + expect(messages.length).toBe(3); + expect(messages[0]).toBe( + '"xpack.actions.customHostSettings[].ssl.rejectUnauthorized" is deprecated.Use "xpack.actions.customHostSettings[].ssl.verificationMode" instead, with the setting "verificationMode:full" eql to "rejectUnauthorized:true", and "verificationMode:none" eql to "rejectUnauthorized:false".' + ); + expect(messages[1]).toBe( + '"xpack.actions.rejectUnauthorized" is deprecated. Use "xpack.actions.verificationMode" instead, with the setting "verificationMode:full" eql to "rejectUnauthorized:true", and "verificationMode:none" eql to "rejectUnauthorized:false".' + ); + expect(messages[2]).toBe( + '"xpack.actions.proxyRejectUnauthorizedCertificates" is deprecated. Use "xpack.actions.proxyVerificationMode" instead, with the setting "proxyVerificationMode:full" eql to "rejectUnauthorized:true",and "proxyVerificationMode:none" eql to "rejectUnauthorized:false".' + ); + }); }); }); diff --git a/x-pack/plugins/actions/server/index.ts b/x-pack/plugins/actions/server/index.ts index bf59a1a11687d..60894f90c0e5d 100644 --- a/x-pack/plugins/actions/server/index.ts +++ b/x-pack/plugins/actions/server/index.ts @@ -82,6 +82,13 @@ export const config: PluginConfigDescriptor = { ], }, }); + return { + unset: [ + { + path: `xpack.actions.customHostSettings.ssl.rejectUnauthorized`, + }, + ], + }; } }, (settings, fromPath, addDeprecation) => { @@ -101,6 +108,13 @@ export const config: PluginConfigDescriptor = { ], }, }); + return { + unset: [ + { + path: `xpack.actions.rejectUnauthorized`, + }, + ], + }; } }, (settings, fromPath, addDeprecation) => { @@ -120,6 +134,13 @@ export const config: PluginConfigDescriptor = { ], }, }); + return { + unset: [ + { + path: `xpack.actions.proxyRejectUnauthorizedCertificates`, + }, + ], + }; } }, (settings, fromPath, addDeprecation) => { diff --git a/x-pack/plugins/task_manager/server/index.ts b/x-pack/plugins/task_manager/server/index.ts index a9b24fdf545a1..78cba6e1cfbce 100644 --- a/x-pack/plugins/task_manager/server/index.ts +++ b/x-pack/plugins/task_manager/server/index.ts @@ -38,6 +38,9 @@ export { export const config: PluginConfigDescriptor = { schema: configSchema, + exposeToUsage: { + max_workers: true, + }, deprecations: () => [ (settings, fromPath, addDeprecation) => { const taskManager = get(settings, fromPath); From 3bdfcc1d579b347723845ba9f635af95d5d7197b Mon Sep 17 00:00:00 2001 From: chrisronline Date: Tue, 28 Sep 2021 10:22:48 -0400 Subject: [PATCH 2/5] PR feedback --- x-pack/plugins/actions/server/index.test.ts | 6 +++--- x-pack/plugins/actions/server/index.ts | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/actions/server/index.test.ts b/x-pack/plugins/actions/server/index.test.ts index 3493e3729a8ef..81f66119ffa5f 100644 --- a/x-pack/plugins/actions/server/index.test.ts +++ b/x-pack/plugins/actions/server/index.test.ts @@ -44,9 +44,9 @@ describe('index', () => { it('should properly unset deprecated configs', () => { const { messages, changedPaths } = applyStackAlertDeprecations({ - customHostSettings: [{ ssl: { rejectUnauthorized: true } }], - rejectUnauthorized: true, - proxyRejectUnauthorizedCertificates: true, + customHostSettings: [{ ssl: { rejectUnauthorized: false } }], + rejectUnauthorized: false, + proxyRejectUnauthorizedCertificates: false, }); expect(changedPaths.unset).toStrictEqual([ 'xpack.actions.customHostSettings.ssl.rejectUnauthorized', diff --git a/x-pack/plugins/actions/server/index.ts b/x-pack/plugins/actions/server/index.ts index 60894f90c0e5d..1e0c6efd250cf 100644 --- a/x-pack/plugins/actions/server/index.ts +++ b/x-pack/plugins/actions/server/index.ts @@ -64,7 +64,8 @@ export const config: PluginConfigDescriptor = { if ( customHostSettings.find( (customHostSchema: CustomHostSettings) => - !!customHostSchema.ssl && !!customHostSchema.ssl.rejectUnauthorized + customHostSchema.hasOwnProperty('ssl') && + customHostSchema.ssl?.hasOwnProperty('rejectUnauthorized') ) ) { addDeprecation({ @@ -93,7 +94,7 @@ export const config: PluginConfigDescriptor = { }, (settings, fromPath, addDeprecation) => { const actions = get(settings, fromPath); - if (!!actions?.rejectUnauthorized) { + if (actions.hasOwnProperty('rejectUnauthorized')) { addDeprecation({ message: `"xpack.actions.rejectUnauthorized" is deprecated. Use "xpack.actions.verificationMode" instead, ` + @@ -119,7 +120,7 @@ export const config: PluginConfigDescriptor = { }, (settings, fromPath, addDeprecation) => { const actions = get(settings, fromPath); - if (!!actions?.proxyRejectUnauthorizedCertificates) { + if (actions.hasOwnProperty('proxyRejectUnauthorizedCertificates')) { addDeprecation({ message: `"xpack.actions.proxyRejectUnauthorizedCertificates" is deprecated. Use "xpack.actions.proxyVerificationMode" instead, ` + From 942af2f322fc613692c4b59c6d37145901d74d86 Mon Sep 17 00:00:00 2001 From: chrisronline Date: Tue, 28 Sep 2021 10:42:30 -0400 Subject: [PATCH 3/5] Be more careful --- x-pack/plugins/actions/server/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/actions/server/index.ts b/x-pack/plugins/actions/server/index.ts index 1e0c6efd250cf..26f7da073223d 100644 --- a/x-pack/plugins/actions/server/index.ts +++ b/x-pack/plugins/actions/server/index.ts @@ -94,7 +94,7 @@ export const config: PluginConfigDescriptor = { }, (settings, fromPath, addDeprecation) => { const actions = get(settings, fromPath); - if (actions.hasOwnProperty('rejectUnauthorized')) { + if (actions?.hasOwnProperty('rejectUnauthorized')) { addDeprecation({ message: `"xpack.actions.rejectUnauthorized" is deprecated. Use "xpack.actions.verificationMode" instead, ` + @@ -120,7 +120,7 @@ export const config: PluginConfigDescriptor = { }, (settings, fromPath, addDeprecation) => { const actions = get(settings, fromPath); - if (actions.hasOwnProperty('proxyRejectUnauthorizedCertificates')) { + if (actions?.hasOwnProperty('proxyRejectUnauthorizedCertificates')) { addDeprecation({ message: `"xpack.actions.proxyRejectUnauthorizedCertificates" is deprecated. Use "xpack.actions.proxyVerificationMode" instead, ` + From 701ad73af61745c9d2473ea01effb85aeca99461 Mon Sep 17 00:00:00 2001 From: chrisronline Date: Wed, 6 Oct 2021 07:56:04 -0500 Subject: [PATCH 4/5] Add test back in --- x-pack/plugins/actions/server/index.test.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/x-pack/plugins/actions/server/index.test.ts b/x-pack/plugins/actions/server/index.test.ts index 81f66119ffa5f..a05d74cd09393 100644 --- a/x-pack/plugins/actions/server/index.test.ts +++ b/x-pack/plugins/actions/server/index.test.ts @@ -33,15 +33,6 @@ const applyStackAlertDeprecations = (settings: Record = {}) => describe('index', () => { describe('deprecations', () => { - it('should deprecate .enabled flag', () => { - const { messages } = applyStackAlertDeprecations({ enabled: false }); - expect(messages).toMatchInlineSnapshot(` - Array [ - "\\"xpack.actions.enabled\\" is deprecated. The ability to disable this plugin will be removed in 8.0.0.", - ] - `); - }); - it('should properly unset deprecated configs', () => { const { messages, changedPaths } = applyStackAlertDeprecations({ customHostSettings: [{ ssl: { rejectUnauthorized: false } }], From 30d550acf0d01545b506bd90f087314e796e7978 Mon Sep 17 00:00:00 2001 From: chrisronline Date: Wed, 6 Oct 2021 08:36:02 -0500 Subject: [PATCH 5/5] Fix types --- x-pack/plugins/actions/server/index.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/plugins/actions/server/index.test.ts b/x-pack/plugins/actions/server/index.test.ts index a05d74cd09393..9021879fa38aa 100644 --- a/x-pack/plugins/actions/server/index.test.ts +++ b/x-pack/plugins/actions/server/index.test.ts @@ -6,6 +6,7 @@ */ import { config } from './index'; import { applyDeprecations, configDeprecationFactory } from '@kbn/config'; +import { configDeprecationsMock } from 'src/core/server/mocks'; const CONFIG_PATH = 'xpack.actions'; const applyStackAlertDeprecations = (settings: Record = {}) => { @@ -19,6 +20,7 @@ const applyStackAlertDeprecations = (settings: Record = {}) => deprecations.map((deprecation) => ({ deprecation, path: CONFIG_PATH, + context: configDeprecationsMock.createContext(), })), () => ({ message }) =>