Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.15] [Response Ops][Alerting] Deleting ad hoc run task if the last …
…schedule entry ends in a timeout (#187496) (#187810) # Backport This will backport the following commits from `main` to `8.15`: - [[Response Ops][Alerting] Deleting ad hoc run task if the last schedule entry ends in a timeout (#187496)](#187496) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Ying Mao","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-07-09T00:07:57Z","message":"[Response Ops][Alerting] Deleting ad hoc run task if the last schedule entry ends in a timeout (#187496)\n\n## Summary\r\n\r\nFixing bug where ad hoc run task was not getting deleted if running the\r\nlast schedule entry and the run times out.\r\n\r\n## To Verify\r\n1. Create a detection rule\r\n2. Add a delay in the ad hoc task runner\r\n```\r\n--- a/x-pack/plugins/alerting/server/task_runner/ad_hoc_task_runner.ts\r\n+++ b/x-pack/plugins/alerting/server/task_runner/ad_hoc_task_runner.ts\r\n@@ -530,6 +530,7 @@ export class AdHocTaskRunner {\r\n } catch (err) {\r\n runMetrics = asErr(err);\r\n }\r\n+ await new Promise((resolve) => setTimeout(resolve, 3100000));\r\n await this.processAdHocRunResults(runMetrics);\r\n```\r\n3. Schedule a backfill for the rule with only one schedule entry\r\n\r\n```\r\nPOST https://localhost:5601/internal/alerting/rules/backfill/_schedule\r\n[\r\n {\r\n \"rule_id\": <ruleId>,\r\n \"start\": \"2024-07-03T13:05:00.000Z\"\r\n }\r\n]\r\n```\r\n\r\n4. Wait for the run to get cancelled then verify that the task was\r\ndeleted.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"c2be810de37479d43661e722e7d7454dacc35c79","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Alerting","release_note:skip","Team:ResponseOps","v8.15.0","v8.16.0"],"title":"[Response Ops][Alerting] Deleting ad hoc run task if the last schedule entry ends in a timeout","number":187496,"url":"https://github.com/elastic/kibana/pull/187496","mergeCommit":{"message":"[Response Ops][Alerting] Deleting ad hoc run task if the last schedule entry ends in a timeout (#187496)\n\n## Summary\r\n\r\nFixing bug where ad hoc run task was not getting deleted if running the\r\nlast schedule entry and the run times out.\r\n\r\n## To Verify\r\n1. Create a detection rule\r\n2. Add a delay in the ad hoc task runner\r\n```\r\n--- a/x-pack/plugins/alerting/server/task_runner/ad_hoc_task_runner.ts\r\n+++ b/x-pack/plugins/alerting/server/task_runner/ad_hoc_task_runner.ts\r\n@@ -530,6 +530,7 @@ export class AdHocTaskRunner {\r\n } catch (err) {\r\n runMetrics = asErr(err);\r\n }\r\n+ await new Promise((resolve) => setTimeout(resolve, 3100000));\r\n await this.processAdHocRunResults(runMetrics);\r\n```\r\n3. Schedule a backfill for the rule with only one schedule entry\r\n\r\n```\r\nPOST https://localhost:5601/internal/alerting/rules/backfill/_schedule\r\n[\r\n {\r\n \"rule_id\": <ruleId>,\r\n \"start\": \"2024-07-03T13:05:00.000Z\"\r\n }\r\n]\r\n```\r\n\r\n4. Wait for the run to get cancelled then verify that the task was\r\ndeleted.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"c2be810de37479d43661e722e7d7454dacc35c79"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"8.15","label":"v8.15.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/187496","number":187496,"mergeCommit":{"message":"[Response Ops][Alerting] Deleting ad hoc run task if the last schedule entry ends in a timeout (#187496)\n\n## Summary\r\n\r\nFixing bug where ad hoc run task was not getting deleted if running the\r\nlast schedule entry and the run times out.\r\n\r\n## To Verify\r\n1. Create a detection rule\r\n2. Add a delay in the ad hoc task runner\r\n```\r\n--- a/x-pack/plugins/alerting/server/task_runner/ad_hoc_task_runner.ts\r\n+++ b/x-pack/plugins/alerting/server/task_runner/ad_hoc_task_runner.ts\r\n@@ -530,6 +530,7 @@ export class AdHocTaskRunner {\r\n } catch (err) {\r\n runMetrics = asErr(err);\r\n }\r\n+ await new Promise((resolve) => setTimeout(resolve, 3100000));\r\n await this.processAdHocRunResults(runMetrics);\r\n```\r\n3. Schedule a backfill for the rule with only one schedule entry\r\n\r\n```\r\nPOST https://localhost:5601/internal/alerting/rules/backfill/_schedule\r\n[\r\n {\r\n \"rule_id\": <ruleId>,\r\n \"start\": \"2024-07-03T13:05:00.000Z\"\r\n }\r\n]\r\n```\r\n\r\n4. Wait for the run to get cancelled then verify that the task was\r\ndeleted.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"c2be810de37479d43661e722e7d7454dacc35c79"}}]}] BACKPORT--> Co-authored-by: Ying Mao <[email protected]>
- Loading branch information