diff --git a/x-pack/plugins/task_manager/server/index.ts b/x-pack/plugins/task_manager/server/index.ts index 79ec16b52987f..f2ad559f02b9c 100644 --- a/x-pack/plugins/task_manager/server/index.ts +++ b/x-pack/plugins/task_manager/server/index.ts @@ -104,4 +104,13 @@ export const config: PluginConfigDescriptor = { }, ]; }, + exposeToUsage: { + claim_strategy: true, + discovery: { + active_nodes_lookback: true, + }, + unsafe: { + exclude_task_types: true, + }, + }, }; diff --git a/x-pack/plugins/task_manager/server/task_store.test.ts b/x-pack/plugins/task_manager/server/task_store.test.ts index cbb1c44dde3fc..029aa2b1760ce 100644 --- a/x-pack/plugins/task_manager/server/task_store.test.ts +++ b/x-pack/plugins/task_manager/server/task_store.test.ts @@ -555,7 +555,14 @@ describe('TaskStore', () => { body: { size: 0, query: { - bool: { filter: [{ term: { type: 'task' } }, { term: { 'task.enabled': true } }] }, + bool: { + filter: { + bool: { + must: [{ term: { type: 'task' } }, { term: { 'task.enabled': true } }], + must_not: [{ term: { 'task.status': 'unrecognized' } }], + }, + }, + }, }, aggs: { testAgg: { terms: { field: 'task.taskType' } } }, }, @@ -578,7 +585,12 @@ describe('TaskStore', () => { must: [ { bool: { - filter: [{ term: { type: 'task' } }, { term: { 'task.enabled': true } }], + filter: { + bool: { + must: [{ term: { type: 'task' } }, { term: { 'task.enabled': true } }], + must_not: [{ term: { 'task.status': 'unrecognized' } }], + }, + }, }, }, { term: { 'task.taskType': 'bar' } }, @@ -600,7 +612,14 @@ describe('TaskStore', () => { body: { size: 0, query: { - bool: { filter: [{ term: { type: 'task' } }, { term: { 'task.enabled': true } }] }, + bool: { + filter: { + bool: { + must: [{ term: { type: 'task' } }, { term: { 'task.enabled': true } }], + must_not: [{ term: { 'task.status': 'unrecognized' } }], + }, + }, + }, }, aggs: { testAgg: { terms: { field: 'task.taskType' } } }, runtime_mappings: { testMapping: { type: 'long', script: { source: `` } } }, diff --git a/x-pack/plugins/task_manager/server/task_store.ts b/x-pack/plugins/task_manager/server/task_store.ts index 0946c5c18d328..6c48f3bd7552d 100644 --- a/x-pack/plugins/task_manager/server/task_store.ts +++ b/x-pack/plugins/task_manager/server/task_store.ts @@ -34,6 +34,7 @@ import { ConcreteTaskInstance, ConcreteTaskInstanceVersion, TaskInstance, + TaskStatus, TaskLifecycle, TaskLifecycleResult, SerializedConcreteTaskInstance, @@ -842,7 +843,12 @@ function ensureAggregationOnlyReturnsEnabledTaskObjects(opts: AggregationOpts): const originalQuery = opts.query; const filterToOnlyTasks = { bool: { - filter: [{ term: { type: 'task' } }, { term: { 'task.enabled': true } }], + filter: { + bool: { + must: [{ term: { type: 'task' } }, { term: { 'task.enabled': true } }], + must_not: [{ term: { 'task.status': TaskStatus.Unrecognized } }], + }, + }, }, }; const query = originalQuery