From ad130b4517ad713254da633742871f6e3d81de88 Mon Sep 17 00:00:00 2001 From: restrry Date: Fri, 13 Dec 2019 10:56:31 +0100 Subject: [PATCH] deprecate xpack.xpack_main.xpack_api_polling_frequency_millis --- x-pack/legacy/plugins/xpack_main/index.js | 4 ---- .../xpack_main/server/lib/__tests__/setup_xpack_main.js | 3 +-- x-pack/plugins/licensing/server/licensing_config.ts | 9 ++++++++- x-pack/plugins/licensing/server/plugin.ts | 2 ++ x-pack/test/licensing_plugin/config.ts | 1 - 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/x-pack/legacy/plugins/xpack_main/index.js b/x-pack/legacy/plugins/xpack_main/index.js index de8928061d141..68fea22e4d905 100644 --- a/x-pack/legacy/plugins/xpack_main/index.js +++ b/x-pack/legacy/plugins/xpack_main/index.js @@ -6,9 +6,6 @@ import { resolve } from 'path'; import dedent from 'dedent'; -import { - XPACK_INFO_API_DEFAULT_POLL_FREQUENCY_IN_MILLIS -} from '../../server/lib/constants'; import { mirrorPluginStatus } from '../../server/lib/mirror_plugin_status'; import { replaceInjectedVars } from './server/lib/replace_injected_vars'; import { setupXPackMain } from './server/lib/setup_xpack_main'; @@ -34,7 +31,6 @@ export const xpackMain = (kibana) => { enabled: Joi.boolean().default(), url: Joi.string().default(), }).default(), // deprecated - xpack_api_polling_frequency_millis: Joi.number().default(XPACK_INFO_API_DEFAULT_POLL_FREQUENCY_IN_MILLIS), }).default(); }, diff --git a/x-pack/legacy/plugins/xpack_main/server/lib/__tests__/setup_xpack_main.js b/x-pack/legacy/plugins/xpack_main/server/lib/__tests__/setup_xpack_main.js index aa404ad0d7464..bd94f951810b0 100644 --- a/x-pack/legacy/plugins/xpack_main/server/lib/__tests__/setup_xpack_main.js +++ b/x-pack/legacy/plugins/xpack_main/server/lib/__tests__/setup_xpack_main.js @@ -49,9 +49,8 @@ describe('setupXPackMain()', () => { ext() {} }); - // Make sure we don't misspell config key. + // Make sure plugins doesn't consume config const configGetStub = sinon.stub().throws(new Error('`config.get` is called with unexpected key.')); - configGetStub.withArgs('xpack.xpack_main.xpack_api_polling_frequency_millis').returns(1234); mockServer.config.returns({ get: configGetStub }); }); diff --git a/x-pack/plugins/licensing/server/licensing_config.ts b/x-pack/plugins/licensing/server/licensing_config.ts index 6cb3e8d9ef3a1..21c44c53207d3 100644 --- a/x-pack/plugins/licensing/server/licensing_config.ts +++ b/x-pack/plugins/licensing/server/licensing_config.ts @@ -5,11 +5,18 @@ */ import { schema, TypeOf } from '@kbn/config-schema'; +import { PluginConfigDescriptor } from 'kibana/server'; -export const config = { +export const config: PluginConfigDescriptor = { schema: schema.object({ pollingFrequency: schema.duration({ defaultValue: '30s' }), }), + deprecations: ({ renameFromRoot }) => [ + renameFromRoot( + 'xpack.xpack_main.xpack_api_polling_frequency_millis', + 'xpack.licensing.pollingFrequency' + ), + ], }; export type LicenseConfigType = TypeOf; diff --git a/x-pack/plugins/licensing/server/plugin.ts b/x-pack/plugins/licensing/server/plugin.ts index c2132b85ad01e..ef60d942c0153 100644 --- a/x-pack/plugins/licensing/server/plugin.ts +++ b/x-pack/plugins/licensing/server/plugin.ts @@ -111,6 +111,8 @@ export class LicensingPlugin implements Plugin { } private createLicensePoller(clusterClient: IClusterClient, pollingFrequency: number) { + this.logger.debug(`Polling Elasticsearch License API with frequency ${pollingFrequency}ms.`); + const intervalRefresh$ = timer(0, pollingFrequency); const { license$, refreshManually } = createLicenseUpdate(intervalRefresh$, this.stop$, () => diff --git a/x-pack/test/licensing_plugin/config.ts b/x-pack/test/licensing_plugin/config.ts index 38965a6c9af5a..810dd3edc76b9 100644 --- a/x-pack/test/licensing_plugin/config.ts +++ b/x-pack/test/licensing_plugin/config.ts @@ -44,7 +44,6 @@ export default async function({ readConfigFile }: FtrConfigProviderContext) { serverArgs: [ ...functionalTestsConfig.get('kbnTestServer.serverArgs'), '--xpack.licensing.pollingFrequency=300', - '--xpack.xpack_main.xpack_api_polling_frequency_millis=300', ], },