From 9b0ec30e60ba98f663fbe46b54d27b273f18fd5e Mon Sep 17 00:00:00 2001 From: Patrick Mueller Date: Mon, 14 Dec 2020 18:52:29 -0500 Subject: [PATCH] [task manager] provide warning when setting max_workers greater than limit (#85574) (#85872) resolves https://github.com/elastic/kibana/issues/56573 In this PR we create a new task manager limit on the config property `xpack.task_manager.max_workers` of 100, but only log a deprecation warning if that property exceeds the limit. We'll enforce the limit in 8.0. The rationale is that it's unlikely going to be useful to run with more than some number of workers, due to the amount of simultaneous work that would end up happening. In practice, too many workers can slow things down more than speed them up. We're setting the limit to 100 for now, but may increase / decrease it based on further research. --- x-pack/plugins/task_manager/server/config.ts | 1 + x-pack/plugins/task_manager/server/index.test.ts | 9 +++++++++ x-pack/plugins/task_manager/server/index.ts | 7 ++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/task_manager/server/config.ts b/x-pack/plugins/task_manager/server/config.ts index 157f01281836d..a22c4484389ae 100644 --- a/x-pack/plugins/task_manager/server/config.ts +++ b/x-pack/plugins/task_manager/server/config.ts @@ -6,6 +6,7 @@ import { schema, TypeOf } from '@kbn/config-schema'; +export const MAX_WORKERS_LIMIT = 100; export const DEFAULT_MAX_WORKERS = 10; export const DEFAULT_POLL_INTERVAL = 3000; export const DEFAULT_MAX_POLL_INACTIVITY_CYCLES = 10; diff --git a/x-pack/plugins/task_manager/server/index.test.ts b/x-pack/plugins/task_manager/server/index.test.ts index 3f25f4403d358..873950f229147 100644 --- a/x-pack/plugins/task_manager/server/index.test.ts +++ b/x-pack/plugins/task_manager/server/index.test.ts @@ -40,4 +40,13 @@ describe('deprecations', () => { `); }); }); + + it('logs a warning if max_workers is over limit', () => { + const { messages } = applyTaskManagerDeprecations({ max_workers: 1000 }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "setting \\"xpack.task_manager.max_workers\\" (1000) greater than 100 is deprecated. Values greater than 100 will not be supported starting in 8.0.", + ] + `); + }); }); diff --git a/x-pack/plugins/task_manager/server/index.ts b/x-pack/plugins/task_manager/server/index.ts index 8f96e10430b39..1696a3ec69c05 100644 --- a/x-pack/plugins/task_manager/server/index.ts +++ b/x-pack/plugins/task_manager/server/index.ts @@ -7,7 +7,7 @@ import { get } from 'lodash'; import { PluginConfigDescriptor, PluginInitializerContext } from 'src/core/server'; import { TaskManagerPlugin } from './plugin'; -import { configSchema, TaskManagerConfig } from './config'; +import { configSchema, TaskManagerConfig, MAX_WORKERS_LIMIT } from './config'; export const plugin = (initContext: PluginInitializerContext) => new TaskManagerPlugin(initContext); @@ -37,6 +37,11 @@ export const config: PluginConfigDescriptor = { `"${fromPath}.index" is deprecated. Multitenancy by changing "kibana.index" will not be supported starting in 8.0. See https://ela.st/kbn-remove-legacy-multitenancy for more details` ); } + if (taskManager?.max_workers > MAX_WORKERS_LIMIT) { + log( + `setting "${fromPath}.max_workers" (${taskManager?.max_workers}) greater than ${MAX_WORKERS_LIMIT} is deprecated. Values greater than ${MAX_WORKERS_LIMIT} will not be supported starting in 8.0.` + ); + } return settings; }, ],