-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Response Ops][Alerting] Fixing bug with using runSoon
on pre-8.x rule
#142505
Conversation
runSoon
on pre-8.x rule
Pinging @elastic/response-ops (Team:ResponseOps) |
? await this.taskManager.get(attributes.scheduledTaskId) | ||
: null; | ||
} catch (err) { | ||
return i18n.translate('xpack.alerting.rulesClient.runSoon.getTaskError', { |
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.
do we really need to return an error at this point? I am wondering if we can just ignore attributes.scheduledTaskId
and just use id
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.
If there is an error getting the task doc at this point, it likely means the task doc doesn't exist, so trying to run it later will result in an error as well. Returning at this point avoids us checking for the task again, which happens when you call taskManager.runSoon
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.
LGTM; left one question about using the alert id if the task id can't be obtained.
@@ -2989,7 +3011,16 @@ export class RulesClient { | |||
}); | |||
} | |||
|
|||
await this.taskManager.runSoon(id); | |||
try { | |||
await this.taskManager.runSoon(attributes.scheduledTaskId ? attributes.scheduledTaskId : id); |
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.
Is there a case where attributes.scheduledTaskId
is falsy but id
would actually be valid? It seems like it would work, but wondering how the rule could get in this state.
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.
Hmm...I guess this could happen previously if something occurred when the rule was getting disabled and the rule SO gets updated with a null scheduledTaskId
but then deleting the associated document ends in an error. If that occurs, the user would be seeing a lot of Rule ran after disabled
errors.
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.
thank you about tell me the history around scheduledTaskId to match the rule ID
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: cc @ymao1 |
…ule (elastic#142505) * Running task using scheduled task id. Adding functional test * dont run if rule is disable * Fixing i18n (cherry picked from commit e007ad6)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…ule (#142505) (#142550) * Running task using scheduled task id. Adding functional test * dont run if rule is disable * Fixing i18n (cherry picked from commit e007ad6) Co-authored-by: Ying Mao <[email protected]>
…ule (elastic#142505) * Running task using scheduled task id. Adding functional test * dont run if rule is disable * Fixing i18n
…ule (elastic#142505) * Running task using scheduled task id. Adding functional test * dont run if rule is disable * Fixing i18n
Resolves #142293
Summary
Updates
runSoon
function to use scheduled task id to run rule instead of rule ID. Using the rule ID causes issues for pre-8.x rules where the scheduled task ID was randomly generated and did not match the rule ID. Also added some additional try/catches to provide more graceful error handling in the case of missing tasks.To Verify
Run Rule
from the menu dropdown. This should return a success toast saying that the rule has been scheduled to run.Checklist