[Task Manager] Adding list of explicitly de-registered task types#123963
[Task Manager] Adding list of explicitly de-registered task types#123963ymao1 merged 16 commits intoelastic:mainfrom
Conversation
…nager/unregistered-task-types
…nager/unregistered-task-types
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
|
Pinging @elastic/response-ops (Team:ResponseOps) |
| */ | ||
| export const REMOVED_TYPES: string[] = [ | ||
| // for testing | ||
| 'sampleTaskRemovedType', |
There was a problem hiding this comment.
Once this PR is merged will we not actually have any type in here?
It raises the question of whether we need the unusedTypes feature at all, no? 🤔
|
This reminds me of an issue I forgot to open up, when looking to disable apm telemetry. I believe when I looked into this, if apm was configured to disable telemetry, the existing telemetry task would eventually get marked as Start here, where the kibana/x-pack/plugins/apm/server/plugin.ts Lines 67 to 94 in 8e8c4b8 The actual task registration is in that kibana/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts Lines 37 to 64 in 8e8c4b8 It wouldn't surprise me to find other task registrations that are conditional like this. Again, I >think< with the change in this PR, such tasks would be ignored, until Kibana was later restarted and when down a conditional path to register the task again. And wouldn't end up in the |
….com/ymao1/kibana into task-manager/unregistered-task-types
@pmuellr Yes, that's correct. With the change in this PR, those tasks would not get marked as |
| 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)) { |
There was a problem hiding this comment.
Don't we need to test the skipped tasks?
There was a problem hiding this comment.
Previously we maintained a list of claimableTaskTypes and skippedTaskTypes. These are all the types that this task manager knows about so if a task is not claimable or skipped, we mark is as unrecognized. Now we are just using claimableTaskTypes to claim and unusedTaskTypes to determine what to mark as unrecognized. Skipped task types will go into the else bucket and get a no-op.
mikecote
left a comment
There was a problem hiding this comment.
Changes LGTM, tested locally the following scenarios:
- Alerting rule with a task in "unrecognized" status returning to idle after upgrade
- Alerting rule with a task definition missing did not make the task have an
unrecognizedstatus - Alerting rule with a task definition missing and part of
REMOVED_TYPEScaused the task status to becomeunrecognized
👍
|
@elasticmachine merge upstream |
| updateFieldsAndMarkAsFailed(fieldUpdates, claimTasksById, ['foo', 'bar'], [], { | ||
| foo: 5, | ||
| bar: 2, | ||
| updateFieldsAndMarkAsFailed({ |
There was a problem hiding this comment.
Clean Code, group the arguments, love it :)
|
@elasticmachine merge upstream |
| 'sampleTaskRemovedType', | ||
|
|
||
| // deprecated in https://github.com/elastic/kibana/pull/121442 | ||
| 'alerting:siem.signals', |
There was a problem hiding this comment.
Tagging you on this PR for awareness. We adding an explicit registry of removed task types that will be marked as unrecognized. Adding alerting:siem.signals due to this PR that removed that rule type. There should be no change to the outcome of that PR (meaning old siem.signals rule types will still be marked as unrecognized)
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: cc @ymao1 |
Resolves #122389
Summary
Adds a list of explicitly de-registered task types and updates claim script to only mark a task as
unrecognizedif the task type exists in that list.In order to explicitly stop registering a task, plugin authors will need to remove the task registration code as well as add the task type to the
REMOVED_TYPESlist inx-pack/plugins/task_manager/server/task_type_dictionary.tsREMOVED_TYPES, it will not be marked asunrecognized. It will just not be claimed.REMOVED_TYPESbut still registered, an error will be thrown. These scenarios should be caught in development.Todo
To Verify
People in Spacerule). Query for the rule in the task manager index and see that status is eitheridleorrunning.idleunrecognized.Checklist