Skip to content

Commit 0666dbd

Browse files
authored
Fix task manager query to return tasks to retry (#63360)
* Fix task manager query to also return tasks to retry * Fix failing jest tests
1 parent 48fd5c0 commit 0666dbd

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

x-pack/plugins/task_manager/server/queries/mark_available_tasks_as_claimed.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
RangeFilter,
1212
mustBeAllOf,
1313
MustCondition,
14-
MustNotCondition,
14+
BoolClauseWithAnyCondition,
1515
} from './query_clauses';
1616

1717
export const TaskWithSchedule: ExistsFilter = {
@@ -54,15 +54,16 @@ export const IdleTaskWithExpiredRunAt: MustCondition<TermFilter | RangeFilter> =
5454
},
5555
};
5656

57-
export const InactiveTasks: MustNotCondition<TermFilter | RangeFilter> = {
57+
// TODO: Fix query clauses to support this
58+
export const InactiveTasks: BoolClauseWithAnyCondition<any> = {
5859
bool: {
5960
must_not: [
6061
{
6162
bool: {
6263
should: [{ term: { 'task.status': 'running' } }, { term: { 'task.status': 'claiming' } }],
64+
must: { range: { 'task.retryAt': { gt: 'now' } } },
6365
},
6466
},
65-
{ range: { 'task.retryAt': { gt: 'now' } } },
6667
],
6768
},
6869
};

x-pack/plugins/task_manager/server/task_store.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,9 @@ describe('TaskStore', () => {
407407
{ term: { 'task.status': 'running' } },
408408
{ term: { 'task.status': 'claiming' } },
409409
],
410+
must: { range: { 'task.retryAt': { gt: 'now' } } },
410411
},
411412
},
412-
{ range: { 'task.retryAt': { gt: 'now' } } },
413413
],
414414
},
415415
},
@@ -553,9 +553,9 @@ describe('TaskStore', () => {
553553
{ term: { 'task.status': 'running' } },
554554
{ term: { 'task.status': 'claiming' } },
555555
],
556+
must: { range: { 'task.retryAt': { gt: 'now' } } },
556557
},
557558
},
558-
{ range: { 'task.retryAt': { gt: 'now' } } },
559559
],
560560
},
561561
},

0 commit comments

Comments
 (0)