Skip to content

Commit

Permalink
Revert "[Task Manager] [8.0] Remove xpack.task_manager.index (#108111
Browse files Browse the repository at this point in the history
…)" (#108398)

This reverts commit 9dce033.
  • Loading branch information
chrisronline authored Aug 12, 2021
1 parent 3c41b3f commit fb215ed
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 15 deletions.
1 change: 1 addition & 0 deletions docs/developer/advanced/running-elasticsearch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ If many other users will be interacting with your remote cluster, you'll want to
[source,bash]
----
kibana.index: '.{YourGitHubHandle}-kibana'
xpack.task_manager.index: '.{YourGitHubHandle}-task-manager-kibana'
----

==== Running remote clusters
Expand Down
3 changes: 3 additions & 0 deletions docs/settings/task-manager-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Task Manager runs background tasks by polling for work on an interval. You can
| `xpack.task_manager.request_capacity`
| How many requests can Task Manager buffer before it rejects new requests. Defaults to 1000.

| `xpack.task_manager.index`
| The name of the index used to store task information. Defaults to `.kibana_task_manager`.

| `xpack.task_manager.max_workers`
| The maximum number of tasks that this Kibana instance will run simultaneously. Defaults to 10.
Starting in 8.0, it will not be possible to set the value greater than 100.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This has three major benefits:

[IMPORTANT]
==============================================
Task definitions for alerts and actions are stored in the index `.kibana_task_manager`.
Task definitions for alerts and actions are stored in the index specified by <<task-manager-settings, `xpack.task_manager.index`>>. The default is `.kibana_task_manager`.
You must have at least one replica of this index for production deployments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ kibana_vars=(
xpack.spaces.enabled
xpack.spaces.maxSpaces
xpack.task_manager.enabled
xpack.task_manager.index
xpack.task_manager.max_attempts
xpack.task_manager.max_poll_inactivity_cycles
xpack.task_manager.max_workers
Expand Down
14 changes: 14 additions & 0 deletions x-pack/plugins/task_manager/server/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('config validation', () => {
"enabled": false,
"request_capacity": 10,
},
"index": ".kibana_task_manager",
"max_attempts": 3,
"max_poll_inactivity_cycles": 10,
"max_workers": 10,
Expand All @@ -41,6 +42,17 @@ describe('config validation', () => {
`);
});

test('the ElastiSearch Tasks index cannot be used for task manager', () => {
const config: Record<string, unknown> = {
index: '.tasks',
};
expect(() => {
configSchema.validate(config);
}).toThrowErrorMatchingInlineSnapshot(
`"[index]: \\".tasks\\" is an invalid Kibana Task Manager index, as it is already in use by the ElasticSearch Tasks Manager"`
);
});

test('the required freshness of the monitored stats config must always be less-than-equal to the poll interval', () => {
const config: Record<string, unknown> = {
monitored_stats_required_freshness: 100,
Expand All @@ -61,6 +73,7 @@ describe('config validation', () => {
"enabled": false,
"request_capacity": 10,
},
"index": ".kibana_task_manager",
"max_attempts": 3,
"max_poll_inactivity_cycles": 10,
"max_workers": 10,
Expand Down Expand Up @@ -103,6 +116,7 @@ describe('config validation', () => {
"enabled": false,
"request_capacity": 10,
},
"index": ".kibana_task_manager",
"max_attempts": 3,
"max_poll_inactivity_cycles": 10,
"max_workers": 10,
Expand Down
9 changes: 9 additions & 0 deletions x-pack/plugins/task_manager/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ export const configSchema = schema.object(
defaultValue: 1000,
min: 1,
}),
/* The name of the index used to store task information. */
index: schema.string({
defaultValue: '.kibana_task_manager',
validate: (val) => {
if (val.toLowerCase() === '.tasks') {
return `"${val}" is an invalid Kibana Task Manager index, as it is already in use by the ElasticSearch Tasks Manager`;
}
},
}),
/* The maximum number of tasks that this Kibana instance will run simultaneously. */
max_workers: schema.number({
defaultValue: DEFAULT_MAX_WORKERS,
Expand Down
8 changes: 0 additions & 8 deletions x-pack/plugins/task_manager/server/constants.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('EphemeralTaskLifecycle', () => {
config: {
enabled: true,
max_workers: 10,
index: 'foo',
max_attempts: 9,
poll_interval: 6000000,
version_conflict_threshold: 80,
Expand Down
11 changes: 11 additions & 0 deletions x-pack/plugins/task_manager/server/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ const applyTaskManagerDeprecations = (settings: Record<string, unknown> = {}) =>
};

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",
]
`);
});
});

it('logs a warning if max_workers is over limit', () => {
const { messages } = applyTaskManagerDeprecations({ max_workers: 1000 });
expect(messages).toMatchInlineSnapshot(`
Expand Down
12 changes: 12 additions & 0 deletions x-pack/plugins/task_manager/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ export const config: PluginConfigDescriptor<TaskManagerConfig> = {
deprecations: () => [
(settings, fromPath, addDeprecation) => {
const taskManager = get(settings, fromPath);
if (taskManager?.index) {
addDeprecation({
documentationUrl: 'https://ela.st/kbn-remove-legacy-multitenancy',
message: `"${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`,
correctiveActions: {
manualSteps: [
`If you rely on this setting to achieve multitenancy you should use Spaces, cross-cluster replication, or cross-cluster search instead.`,
`To migrate to Spaces, we encourage using saved object management to export your saved objects from a tenant into the default tenant in a space.`,
],
},
});
}
if (taskManager?.max_workers > MAX_WORKERS_LIMIT) {
addDeprecation({
message: `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.`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('managed configuration', () => {
const context = coreMock.createPluginInitializerContext<TaskManagerConfig>({
enabled: true,
max_workers: 10,
index: 'foo',
max_attempts: 9,
poll_interval: 3000,
version_conflict_threshold: 80,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('Configuration Statistics Aggregator', () => {
const configuration: TaskManagerConfig = {
enabled: true,
max_workers: 10,
index: 'foo',
max_attempts: 9,
poll_interval: 6000000,
version_conflict_threshold: 80,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('createMonitoringStatsStream', () => {
const configuration: TaskManagerConfig = {
enabled: true,
max_workers: 10,
index: 'foo',
max_attempts: 9,
poll_interval: 6000000,
version_conflict_threshold: 80,
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/task_manager/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('TaskManagerPlugin', () => {
const pluginInitializerContext = coreMock.createPluginInitializerContext<TaskManagerConfig>({
enabled: true,
max_workers: 10,
index: 'foo',
max_attempts: 9,
poll_interval: 3000,
version_conflict_threshold: 80,
Expand Down Expand Up @@ -57,6 +58,7 @@ describe('TaskManagerPlugin', () => {
const pluginInitializerContext = coreMock.createPluginInitializerContext<TaskManagerConfig>({
enabled: true,
max_workers: 10,
index: 'foo',
max_attempts: 9,
poll_interval: 3000,
version_conflict_threshold: 80,
Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/task_manager/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { createMonitoringStats, MonitoringStats } from './monitoring';
import { EphemeralTaskLifecycle } from './ephemeral_task_lifecycle';
import { EphemeralTask } from './task';
import { registerTaskManagerUsageCollector } from './usage';
import { TASK_MANAGER_INDEX } from './constants';

export type TaskManagerSetupContract = {
/**
Expand Down Expand Up @@ -115,7 +114,7 @@ export class TaskManagerPlugin
}

return {
index: TASK_MANAGER_INDEX,
index: this.config.index,
addMiddleware: (middleware: Middleware) => {
this.assertStillInSetup('add Middleware');
this.middleware = addMiddlewareToChain(this.middleware, middleware);
Expand All @@ -135,7 +134,7 @@ export class TaskManagerPlugin
serializer,
savedObjectsRepository,
esClient: elasticsearch.createClient('taskManager').asInternalUser,
index: TASK_MANAGER_INDEX,
index: this.config!.index,
definitions: this.definitions,
taskManagerId: `kibana:${this.taskManagerId!}`,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('TaskPollingLifecycle', () => {
config: {
enabled: true,
max_workers: 10,
index: 'foo',
max_attempts: 9,
poll_interval: 6000000,
version_conflict_threshold: 80,
Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/task_manager/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import mappings from './mappings.json';
import { migrations } from './migrations';
import { TaskManagerConfig } from '../config.js';
import { getOldestIdleActionTask } from '../queries/oldest_idle_action_task';
import { TASK_MANAGER_INDEX } from '../constants';

export function setupSavedObjects(
savedObjects: SavedObjectsServiceSetup,
Expand All @@ -24,11 +23,11 @@ export function setupSavedObjects(
convertToAliasScript: `ctx._id = ctx._source.type + ':' + ctx._id; ctx._source.remove("kibana")`,
mappings: mappings.task as SavedObjectsTypeMappingDefinition,
migrations,
indexPattern: TASK_MANAGER_INDEX,
indexPattern: config.index,
excludeOnUpgrade: async ({ readonlyEsClient }) => {
const oldestNeededActionParams = await getOldestIdleActionTask(
readonlyEsClient,
TASK_MANAGER_INDEX
config.index
);

// Delete all action tasks that have failed and are no longer needed
Expand Down

0 comments on commit fb215ed

Please sign in to comment.