Skip to content

chore(deletions): Remove old group deletion task #96457

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
merged 4 commits into from
Jul 28, 2025

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented Jul 25, 2025

This deletes the old task plus updates some tests to work properly with the new task.

Follow-up to #96310.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 25, 2025
@armenzg armenzg changed the title Delete old group deletion task chore(deletions): Remove old group deletion task Jul 25, 2025
Copy link

codecov bot commented Jul 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #96457      +/-   ##
==========================================
- Coverage   83.83%   83.82%   -0.01%     
==========================================
  Files       10642    10643       +1     
  Lines      614424   614375      -49     
  Branches    24127    24127              
==========================================
- Hits       515087   515022      -65     
- Misses      98956    98972      +16     
  Partials      381      381              

@@ -142,9 +73,6 @@ def delete_groups_for_project(
f"is greater than GROUP_CHUNK_SIZE"
)

# This is a no-op on the Snuba side, however, one day it may not be.
eventstream_state = eventstream.backend.start_delete_groups(project_id, object_ids)
Copy link
Member Author

Choose a reason for hiding this comment

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

If we have Snuba events to delete we will call it here:

eventstream_state = eventstream.backend.start_delete_groups(project_id, group_ids)
eventstream.backend.end_delete_groups(eventstream_state)

We have always been calling it more than once, this can be seen in the tests:
Image

@@ -4311,78 +4311,55 @@ def assert_deleted_groups(self, groups: Sequence[Group]) -> None:
assert not Group.objects.filter(id=group.id).exists()
assert not GroupHash.objects.filter(group_id=group.id).exists()

@patch("sentry.eventstream.backend")
def test_delete_by_id(self, mock_eventstream: MagicMock) -> None:
Copy link
Member Author

Choose a reason for hiding this comment

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

This test does a few more things than testing that using id= works. I have simplified the test.


self.login_as(user=self.user)
with self.feature("organizations:global-views"):
response = self.get_response(
qs_params={"id": [group1.id, group2.id], "group4": group4.id}
Copy link
Member Author

Choose a reason for hiding this comment

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

I think the original test introduced this non-useful parameter by mistake: "group4": group4.id

extra_data=(
{
"transaction_id": transaction_id,
"project_id": self.project.id,
Copy link
Member Author

Choose a reason for hiding this comment

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

As I mentioned in one of my other PRs, project_id is a required parameter for Snuba (besides the group ids).

assert mock_send.call_args_list == [
call(
self.project.id,
"start_delete_groups",
Copy link
Member Author

Choose a reason for hiding this comment

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

The start call.

),
call(
self.project.id,
"end_delete_groups",
Copy link
Member Author

Choose a reason for hiding this comment

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

The end call.


self.assert_deleted_groups(groups_1 + groups_2)

def test_bulk_delete_for_many_projects_with_option(self) -> None:
Copy link
Member Author

Choose a reason for hiding this comment

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

This test is now the default one.

@patch("sentry.utils.audit.log_service.record_audit_log")
def test_delete_by_id(self, mock_record_audit_log, mock_eventstream):
Copy link
Member Author

Choose a reason for hiding this comment

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

Similar changes as what you read on the previous test, however, this test does not do any of the eventstream tests.


self.login_as(user=self.user)
# Group 4 will not be deleted because it belongs to a different project
Copy link
Member Author

Choose a reason for hiding this comment

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

We already have other tests handling cross project deleting.

@armenzg armenzg self-assigned this Jul 25, 2025
@armenzg armenzg marked this pull request as ready for review July 25, 2025 18:59
@armenzg armenzg requested review from a team as code owners July 25, 2025 18:59
@armenzg armenzg requested a review from markstory July 25, 2025 19:07
Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

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

👏

@armenzg armenzg merged commit 836b997 into master Jul 28, 2025
65 checks passed
@armenzg armenzg deleted the 1/delete_old_task/armenzg branch July 28, 2025 16:06
Copy link

sentry-io bot commented Jul 28, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

Did you find this useful? React with a 👍 or 👎

andrewshie-sentry pushed a commit that referenced this pull request Aug 4, 2025
This deletes the old task plus updates some tests to work properly with
the new task.

Follow-up to #96310.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants