Skip to content

Commit

Permalink
Deprecate xpack.task_manager.index setting (#84155)
Browse files Browse the repository at this point in the history
* Deprecate `xpack.task_manager.index` setting

* Updating developer docs about configuring task manager settings
  • Loading branch information
kobelb authored Nov 25, 2020
1 parent b3430e3 commit 58297fa
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/task_manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The task_manager can be configured via `taskManager` config options (e.g. `taskM
- `max_attempts` - The maximum number of times a task will be attempted before being abandoned as failed
- `poll_interval` - How often the background worker should check the task_manager index for more work
- `max_poll_inactivity_cycles` - How many poll intervals is work allowed to block polling for before it's timed out. This does not include task execution, as task execution does not block the polling, but rather includes work needed to manage Task Manager's state.
- `index` - The name of the index that the task_manager
- `index` - **deprecated** The name of the index that the task_manager will use. This is deprecated, and will be removed starting in 8.0
- `max_workers` - The maximum number of tasks a Kibana will run concurrently (defaults to 10)
- `credentials` - Encrypted user credentials. All tasks will run in the security context of this user. See [this issue](https://github.com/elastic/dev/issues/1045) for a discussion on task scheduler security.
- `override_num_workers`: An object of `taskType: number` that overrides the `num_workers` for tasks
Expand Down
43 changes: 43 additions & 0 deletions x-pack/plugins/task_manager/server/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { config } from './index';
import { applyDeprecations, configDeprecationFactory } from '@kbn/config';

const CONFIG_PATH = 'xpack.task_manager';

const applyTaskManagerDeprecations = (settings: Record<string, unknown> = {}) => {
const deprecations = config.deprecations!(configDeprecationFactory);
const deprecationMessages: string[] = [];
const _config = {
[CONFIG_PATH]: settings,
};
const migrated = applyDeprecations(
_config,
deprecations.map((deprecation) => ({
deprecation,
path: CONFIG_PATH,
})),
(msg) => deprecationMessages.push(msg)
);
return {
messages: deprecationMessages,
migrated,
};
};

describe('deprecations', () => {
['.foo', '.kibana_task_manager'].forEach((index) => {
it('logs a warning if index is set', () => {
const { messages } = applyTaskManagerDeprecations({ index });
expect(messages).toMatchInlineSnapshot(`
Array [
"\\"xpack.task_manager.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",
]
`);
});
});
});
18 changes: 15 additions & 3 deletions x-pack/plugins/task_manager/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { PluginInitializerContext } from 'src/core/server';
import { get } from 'lodash';
import { PluginConfigDescriptor, PluginInitializerContext } from 'src/core/server';
import { TaskManagerPlugin } from './plugin';
import { configSchema } from './config';
import { configSchema, TaskManagerConfig } from './config';

export const plugin = (initContext: PluginInitializerContext) => new TaskManagerPlugin(initContext);

Expand All @@ -26,6 +27,17 @@ export {
TaskManagerStartContract,
} from './plugin';

export const config = {
export const config: PluginConfigDescriptor<TaskManagerConfig> = {
schema: configSchema,
deprecations: () => [
(settings, fromPath, log) => {
const taskManager = get(settings, fromPath);
if (taskManager?.index) {
log(
`"${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`
);
}
return settings;
},
],
};

0 comments on commit 58297fa

Please sign in to comment.