Skip to content

Commit

Permalink
Fix task manager query to return tasks to retry (#63360) (#63405)
Browse files Browse the repository at this point in the history
* Fix task manager query to also return tasks to retry

* Fix failing jest tests
  • Loading branch information
mikecote authored Apr 13, 2020
1 parent e68fe90 commit 051d9f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
RangeFilter,
mustBeAllOf,
MustCondition,
MustNotCondition,
BoolClauseWithAnyCondition,
} from './query_clauses';

export const TaskWithSchedule: ExistsFilter = {
Expand Down Expand Up @@ -54,15 +54,16 @@ export const IdleTaskWithExpiredRunAt: MustCondition<TermFilter | RangeFilter> =
},
};

export const InactiveTasks: MustNotCondition<TermFilter | RangeFilter> = {
// TODO: Fix query clauses to support this
export const InactiveTasks: BoolClauseWithAnyCondition<any> = {
bool: {
must_not: [
{
bool: {
should: [{ term: { 'task.status': 'running' } }, { term: { 'task.status': 'claiming' } }],
must: { range: { 'task.retryAt': { gt: 'now' } } },
},
},
{ range: { 'task.retryAt': { gt: 'now' } } },
],
},
};
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/task_manager/server/task_store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ describe('TaskStore', () => {
{ term: { 'task.status': 'running' } },
{ term: { 'task.status': 'claiming' } },
],
must: { range: { 'task.retryAt': { gt: 'now' } } },
},
},
{ range: { 'task.retryAt': { gt: 'now' } } },
],
},
},
Expand Down Expand Up @@ -553,9 +553,9 @@ describe('TaskStore', () => {
{ term: { 'task.status': 'running' } },
{ term: { 'task.status': 'claiming' } },
],
must: { range: { 'task.retryAt': { gt: 'now' } } },
},
},
{ range: { 'task.retryAt': { gt: 'now' } } },
],
},
},
Expand Down

0 comments on commit 051d9f6

Please sign in to comment.