Skip to content

[RAM] 142183 create bulk delete on rules #142466

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

Conversation

guskovaue
Copy link
Contributor

@guskovaue guskovaue commented Oct 3, 2022

Connected with: #142183

Summary

I am working on getting alive bulk delete for rules.

I this PR I've created a new internal endpoint _bulk_delete.
This endpoint is getting rules ids or filter as parameter and return object like this: { errors: [], total }.

Decide to stick with only backend because PR is already pretty big. But I've tested it from UI as well.

Checklist

@guskovaue guskovaue force-pushed the RAM-142183-create-bulk-delete-on-rules branch from a99497f to 09e4559 Compare October 7, 2022 13:01
@guskovaue guskovaue changed the title Ram 142183 create bulk delete on rules [RAM] 142183 create bulk delete on rules Oct 12, 2022
@guskovaue guskovaue added Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.6.0 release_note:feature Makes this part of the condensed release notes labels Oct 13, 2022
@guskovaue guskovaue self-assigned this Oct 13, 2022
@XavierM XavierM added release_note:enhancement and removed release_note:feature Makes this part of the condensed release notes labels Oct 13, 2022
@guskovaue guskovaue removed request for a team, pzl, maximpn and paul-tavares October 22, 2022 13:41
@guskovaue
Copy link
Contributor Author

I just tried via POSTMAN to issue a PATCH command to https://localhost:5601/internal/alerting/rules/_bulk_delete with an empty request body and saw all of my rules deleted when I was expecting to get an error message telling me I need to specify ids or a filter.

@ymao1 Yes, I see now! It's bad. I've tested sending no arguments, but I think I did not have any rules in my account, so I received an error.
Sorry for that. Here I've fixed it and wrote more test to check this part of validation: 40e7fd1

Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the latest changes and bulk deleting via POSTMAN works as expected. There is still a question of what the task manager bulkRemoveIfExists should return if some tasks are deleted and some error and we need to handle any potential errors from taskManager.bulkRemoveIfExists in the rules client so we do not introduce the possibility of Unhandled promise rejections.

@guskovaue
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the latest updates! Approving to unblock :)

I left one comment here about not needing to check for ensureRuleTypeEnabled during bulk delete (we don't check for it during normal delete so I don't think it's needed for bulk delete?)

Also would like to see functional tests for the new task manager functions in x-pack/test/plugin_api_integration/test_suites/task_manager/task_management.ts but I'm fine with that being done as a followup.

@guskovaue guskovaue force-pushed the RAM-142183-create-bulk-delete-on-rules branch from 9f32f95 to 8668810 Compare October 25, 2022 12:39
@guskovaue guskovaue enabled auto-merge (squash) October 25, 2022 13:56
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
alerting 24 26 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @guskovaue

@guskovaue guskovaue merged commit 6266f5a into elastic:main Oct 25, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:enhancement Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants