Skip to content
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

[Files] Adds bulk delete method #155628

Merged
merged 4 commits into from
Apr 26, 2023
Merged

Conversation

vadimkibana
Copy link
Contributor

@vadimkibana vadimkibana commented Apr 24, 2023

Summary

Closes #154286

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@vadimkibana vadimkibana added review release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) feature:Files v8.8.0 labels Apr 24, 2023
@vadimkibana vadimkibana marked this pull request as ready for review April 24, 2023 14:11
@vadimkibana vadimkibana requested a review from a team as a code owner April 24, 2023 14:11
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

@vadimkibana vadimkibana changed the title Bulk delete [Files] Add bulk delete method Apr 24, 2023
@vadimkibana vadimkibana changed the title [Files] Add bulk delete method [Files] Adds bulk delete method Apr 24, 2023
@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
files 5 6 +1
Unknown metric groups

API count

id before after diff
files 215 217 +2

ESLint disabled line counts

id before after diff
enterpriseSearch 17 19 +2
securitySolution 395 398 +3
total +5

Total ESLint disabled count

id before after diff
enterpriseSearch 18 20 +2
securitySolution 475 478 +3
total +5

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

@vadimkibana vadimkibana enabled auto-merge (squash) April 25, 2023 14:15
public async bulkDeleteFiles({
ids,
}: BulkDeleteFilesArgs): Promise<Array<PromiseSettledResult<void>>> {
const promises = ids.map((id) => bulkDeleteConcurrency(() => this.deleteFile({ id })));
Copy link
Contributor

Choose a reason for hiding this comment

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

I know there's complexities here that I'm not aware of but would it be possible to use the saved object client's bulkDelete functionality?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you look at the private get below you can see that there is some logic encapsulated. It converts the id to a File instance and calls its delete() method which then delete the content from the blob storage, calls the updateFileState to change the state, delete the SO and finally logs some events logAuditEvent 😊

That's what we hook into.

Copy link
Contributor Author

@vadimkibana vadimkibana Apr 26, 2023

Choose a reason for hiding this comment

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

+1 to what @sebelga mentioned, essentially, before even deleting the saved object metadata document, we need to delete the blob contents first, which is stored in a different place.

Copy link
Contributor

@sebelga sebelga left a comment

Choose a reason for hiding this comment

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

LGTM! Great job 👍

@vadimkibana vadimkibana merged commit c640c25 into elastic:main Apr 26, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Apr 26, 2023
jloleysens added a commit to jloleysens/kibana that referenced this pull request Apr 26, 2023
* main: (1294 commits)
  [SecuritySolution] Refactor security packages (elastic#155365)
  [Discover] Show "Temporary" badge for ad-hoc data views in Alerts flyout (elastic#155717)
  [RAM] Conditional actions feedback on pr review (elastic#155804)
  [Files] Adds bulk delete method (elastic#155628)
  [Lens] Use proper way to generate absolute short URL (elastic#155512)
  [Guided onboarding] Use Kibana features to grant access (elastic#155065)
  [Index Management] Fix duped mock (elastic#155844)
  [Lens] Enhance visualization modifier popup with layer palette (elastic#155280)
  Fix flaky combobox tests on role management screen (elastic#155711)
  [Infrastructure UI] Create InventoryViewsService and InventoryViewsClient (elastic#155126)
  [Fleet] always create agent upload write indices (elastic#155729)
  [Fleet] [Cloud Security Posture] Add CloudFormation agent install method (elastic#155045)
  Add tech preview label for search applications (elastic#155649)
  [ML] AIOps: Stabilize flaky functional tests. (elastic#155710)
  [ES UI Shared] Migrate JsonEditor to monaco (elastic#155610)
  [Security Solution] Fixes security_solution storybooks always rendering in a flyout (elastic#155814)
  [Synthetics] Make error popover disappear `onMouseLeave` of metric item card (elastic#155800)
  Remove Exploratory View components from Observability (elastic#155629)
  [Discover] Remove redundant "Filter was added" toast (elastic#155645)
  [RAM][Security Solution][Alerts] Support the ability to trigger a rule action per alert generated (elastic#153611) (elastic#155384)
  ...
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 feature:Files release_note:skip Skip the PR/issue when compiling release notes review Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Files] File service bulk delete
6 participants