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

Prevent deletion of event definitions which are still being referenced #14792

Merged
merged 17 commits into from Mar 9, 2023

Conversation

patrickmann
Copy link
Contributor

@patrickmann patrickmann commented Feb 27, 2023

Resolves #14302

Check for dependencies when deleting event definitions. Return information about the dependent events, when deletion is not possible.

Introduces a new pluggable EventResolver, since event definitions are pluggable.
Also see related PR Graylog2/graylog-plugin-enterprise#4765

@patrickmann patrickmann changed the title Eventresolver Prevent deletion of event definitions which are still being referenced Feb 27, 2023
@patrickmann patrickmann marked this pull request as draft February 27, 2023 15:55
@patrickmann patrickmann marked this pull request as ready for review March 6, 2023 14:13
@patrickmann patrickmann requested review from thll and grotlue March 6, 2023 14:20
@@ -23,6 +23,11 @@ public ValidationFailureException(ValidationResult validationResult) {
this.validationResult = validationResult;
}

public ValidationFailureException(ValidationResult validationResult, String message) {
super(message);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that message used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need that message to return an error result from EventDefinitionsResource::delete.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unless I'm missing something, it's really not being used, so I think we should rather remove that constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

throw new ValidationFailureException(validationResult, msg);

Copy link
Contributor

@grotlue grotlue left a comment

Choose a reason for hiding this comment

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

Code-wise (FE) it looks good!

Testing results

  • ❌ When I delete events using the bath delete, the event title is not shown (for both, one or more events)
Monosnap.screencast.2023-03-07.11-46-17.mp4

  • ✅ When I delete an event that is used in event correlation via batch delete it is not deleted
  • ✅ When I delete an event that is used in event correlation via batch delete an error message is shown
  • ✅ When I delete an event that is used in event correlation via delete action it is not deleted
  • ✅ When I delete an event that is used in event correlation via delete action an error message is shown
  • ✅ When I delete an event that has dependencies on other events it is deleted successfully
  • ✅ When I delete an event that has no dependencies and is not used in correlation it is deleted successfully
Monosnap.screencast.2023-03-07.11-51-13.mp4

There is one case that I think could be improved from a user perspective

  • ⚠️ When I delete multiple events (Event 1 and Event 2), where Event 2 is using Event 1 in correlation and Event 1 & Event 2 are not used in any other event, currently the deletion of Event 1 will fail, resulting in an error message and the deletion modal still being open.

I think in this case we can safely delete Event 1 as well, as it is not used anywhere else, this is what I would expect as a user. However, I am not sure how much effort it is to implement this logic.

Monosnap.screencast.2023-03-07.11-58-43.mp4

@patrickmann
Copy link
Contributor Author

@grotlue re the last test case: That would indeed be better, but would require a fair bit of refactoring in the backend. I'd prefer to leave it as is.

@ousmaneo
Copy link
Contributor

ousmaneo commented Mar 7, 2023

❌ When I delete events using the bath delete, the event title is not shown (for both, one or more events)

Here we should show the number of items affected by bulk action. Fixed that

@patrickmann patrickmann requested a review from thll March 7, 2023 13:27
@ousmaneo ousmaneo requested a review from grotlue March 7, 2023 13:31
Copy link
Contributor

@grotlue grotlue left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the bug, looks good now!
Screenshot 2023-03-07 at 16 22 29

@patrickmann patrickmann merged commit 064b0b4 into master Mar 9, 2023
@patrickmann patrickmann deleted the eventresolver branch March 9, 2023 11:28
R4103N pushed a commit to R4103N/graylog2-server that referenced this pull request Mar 31, 2023
Graylog2#14792)

* add event resolver

* minor refactoring

* checkpoint

* Throw ValidationResultException

* Add a message to ValidationFailureException

* cl

* show dependency error

* improve message text

* fix linter

* show number of item affected by action

* review feedback

* remove unused constructor in ValidationFailureException

---------

Co-authored-by: Ousmane Samba <ousmane@graylog.com>
Co-authored-by: Othello Maurer <othello@graylog.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a warning when a linked event definition is deleted which is referenced in a correlation
4 participants