-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Task Manager] Adding list of explicitly de-registered task types #123963
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
Merged
ymao1
merged 16 commits into
elastic:main
from
ymao1:task-manager/unregistered-task-types
Feb 15, 2022
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1ef085d
Adding REMOVED_TYPES to task manager and only marking those types as …
ymao1 cf0726d
Merge branch 'main' of https://github.com/elastic/kibana into task-ma…
ymao1 7dbccbc
Adding unit tests
ymao1 976a14f
Fixing functional test
ymao1 1a0453b
Merge branch 'main' of https://github.com/elastic/kibana into task-ma…
ymao1 7a5cf7b
Throwing error when registering a removed task type
ymao1 e126374
Adding migration
ymao1 821bc7d
Adding functional tests
ymao1 ed31d92
Merge branch 'main' into task-manager/unregistered-task-types
kibanamachine 0c40a92
Merge branch 'main' into task-manager/unregistered-task-types
kibanamachine 249a912
Merging in main
ymao1 770cb4a
Merge branch 'task-manager/unregistered-task-types' of https://github…
ymao1 bda2fdd
Cleanup
ymao1 09d30cd
Merge branch 'main' into task-manager/unregistered-task-types
kibanamachine 2fa9e16
Merge branch 'main' into task-manager/unregistered-task-types
kibanamachine 2dee057
Adding disabled siem signals rule type
ymao1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,15 +47,16 @@ describe('mark_available_tasks_as_claimed', () => { | |
| // status running or claiming with a retryAt <= now. | ||
| shouldBeOneOf(IdleTaskWithExpiredRunAt, RunningOrClaimingTaskWithExpiredRetryAt) | ||
| ), | ||
| script: updateFieldsAndMarkAsFailed( | ||
| script: updateFieldsAndMarkAsFailed({ | ||
| fieldUpdates, | ||
| claimTasksById || [], | ||
| definitions.getAllTypes(), | ||
| [], | ||
| Array.from(definitions).reduce((accumulator, [type, { maxAttempts }]) => { | ||
| claimTasksById: claimTasksById || [], | ||
| claimableTaskTypes: definitions.getAllTypes(), | ||
| skippedTaskTypes: [], | ||
| unusedTaskTypes: [], | ||
| taskMaxAttempts: Array.from(definitions).reduce((accumulator, [type, { maxAttempts }]) => { | ||
| return { ...accumulator, [type]: maxAttempts || defaultMaxAttempts }; | ||
| }, {}) | ||
| ), | ||
| }, {}), | ||
| }), | ||
| sort: SortByRunAtAndRetryAt, | ||
| }).toEqual({ | ||
| query: { | ||
|
|
@@ -126,7 +127,7 @@ if (doc['task.runAt'].size()!=0) { | |
| ctx._source.task.status = "claiming"; ${Object.keys(fieldUpdates) | ||
| .map((field) => `ctx._source.task.${field}=params.fieldUpdates.${field};`) | ||
| .join(' ')} | ||
| } else if (!params.skippedTaskTypes.contains(ctx._source.task.taskType)) { | ||
| } else if (params.unusedTaskTypes.contains(ctx._source.task.taskType)) { | ||
| ctx._source.task.status = "unrecognized"; | ||
| } else { | ||
| ctx.op = "noop"; | ||
|
|
@@ -140,6 +141,7 @@ if (doc['task.runAt'].size()!=0) { | |
| claimTasksById: [], | ||
| claimableTaskTypes: ['sampleTask', 'otherTask'], | ||
| skippedTaskTypes: [], | ||
| unusedTaskTypes: [], | ||
| taskMaxAttempts: { | ||
| sampleTask: 5, | ||
| otherTask: 1, | ||
|
|
@@ -164,9 +166,16 @@ if (doc['task.runAt'].size()!=0) { | |
| ]; | ||
|
|
||
| expect( | ||
| updateFieldsAndMarkAsFailed(fieldUpdates, claimTasksById, ['foo', 'bar'], [], { | ||
| foo: 5, | ||
| bar: 2, | ||
| updateFieldsAndMarkAsFailed({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clean Code, group the arguments, love it :) |
||
| fieldUpdates, | ||
| claimTasksById, | ||
| claimableTaskTypes: ['foo', 'bar'], | ||
| skippedTaskTypes: [], | ||
| unusedTaskTypes: [], | ||
| taskMaxAttempts: { | ||
| foo: 5, | ||
| bar: 2, | ||
| }, | ||
| }) | ||
| ).toMatchObject({ | ||
| source: ` | ||
|
|
@@ -182,7 +191,7 @@ if (doc['task.runAt'].size()!=0) { | |
| ctx._source.task.status = "claiming"; ${Object.keys(fieldUpdates) | ||
| .map((field) => `ctx._source.task.${field}=params.fieldUpdates.${field};`) | ||
| .join(' ')} | ||
| } else if (!params.skippedTaskTypes.contains(ctx._source.task.taskType)) { | ||
| } else if (params.unusedTaskTypes.contains(ctx._source.task.taskType)) { | ||
| ctx._source.task.status = "unrecognized"; | ||
| } else { | ||
| ctx.op = "noop"; | ||
|
|
@@ -196,6 +205,7 @@ if (doc['task.runAt'].size()!=0) { | |
| ], | ||
| claimableTaskTypes: ['foo', 'bar'], | ||
| skippedTaskTypes: [], | ||
| unusedTaskTypes: [], | ||
| taskMaxAttempts: { | ||
| foo: 5, | ||
| bar: 2, | ||
|
|
@@ -213,9 +223,16 @@ if (doc['task.runAt'].size()!=0) { | |
| }; | ||
|
|
||
| expect( | ||
| updateFieldsAndMarkAsFailed(fieldUpdates, [], ['foo', 'bar'], [], { | ||
| foo: 5, | ||
| bar: 2, | ||
| updateFieldsAndMarkAsFailed({ | ||
| fieldUpdates, | ||
| claimTasksById: [], | ||
| claimableTaskTypes: ['foo', 'bar'], | ||
| skippedTaskTypes: [], | ||
| unusedTaskTypes: [], | ||
| taskMaxAttempts: { | ||
| foo: 5, | ||
| bar: 2, | ||
| }, | ||
| }).source | ||
| ).toMatch(/ctx.op = "noop"/); | ||
| }); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to test the skipped tasks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously we maintained a list of
claimableTaskTypesandskippedTaskTypes. These are all the types that this task manager knows about so if a task is not claimable or skipped, we mark is asunrecognized. Now we are just usingclaimableTaskTypesto claim andunusedTaskTypesto determine what to mark asunrecognized. Skipped task types will go into theelsebucket and get ano-op.