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

[Cloud Security] Disable/Enable rule takes too long #182768

Conversation

seanrathier
Copy link
Contributor

@seanrathier seanrathier commented May 7, 2024

Summary

This change resolves the Benchmark Rules page's performance when enabling or disabling rules. Most of the work was converting the change_csp_rule_state to use the ReactQuery useMutation hook. This change introduces optimistic updating of the cached data, while at the same time performing the HTTP request to bulk update to mute or unmute the rules.

Should anything fail with the HTP request, the snapshot of the data taken before the cache was optimistically updated will replace the mutated data.

Other changes:

  • Removed the refetch call in the rules_table and instead opted to use the invalidateQueries
  • Removed the await from the original invalidateQueries as these can be executed in the background.
  • Removed useMemo hook from the table columns because there was no visual difference and it introduces more complexity for the execution.
Screen.Recording.2024-05-09.at.11.41.33.AM.mov

Checklisthttps://github.com//pull/182768/files

For maintainers

@seanrathier seanrathier linked an issue May 7, 2024 that may be closed by this pull request
@seanrathier seanrathier added Team:Cloud Security Cloud Security team related release_note:skip Skip the PR/issue when compiling release notes labels May 8, 2024
@seanrathier
Copy link
Contributor Author

/ci

@seanrathier seanrathier marked this pull request as ready for review May 9, 2024 15:51
@seanrathier seanrathier requested a review from a team as a code owner May 9, 2024 15:51
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security)

@seanrathier
Copy link
Contributor Author

/ci

Copy link
Contributor

@opauloh opauloh left a comment

Choose a reason for hiding this comment

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

overall LGTM, just some comments,

Great test coverage 🚀

Copy link
Contributor

@opauloh opauloh left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@JordanSh JordanSh left a comment

Choose a reason for hiding this comment

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

Looks great, Sean 👑

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #55 / endpoint For each artifact list under management When on the Trusted applications entries list "after each" hook for "should not show page title if there is no Trusted applications entry"

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cloudSecurityPosture 448.5KB 448.7KB +190.0B

History

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

@seanrathier seanrathier merged commit e759c40 into elastic:main May 21, 2024
18 checks passed
@seanrathier seanrathier deleted the 177279-cloud-security-disableenable-rule-takes-too-long-B branch May 21, 2024 19:56
@kibanamachine kibanamachine added v8.15.0 backport:skip This commit does not require backporting labels May 21, 2024
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:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Cloud Security] Disable/Enable rule takes too long
8 participants