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

Deprecate xpack.task_manager.index setting #84155

Merged
merged 3 commits into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
},
],
};