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

chore(alerts): Remove activated alert models #83255

Merged
merged 4 commits into from
Jan 10, 2025

Conversation

ceorourke
Copy link
Member

Follow up to #83248 to remove the activated alert models.

@ceorourke ceorourke requested review from a team as code owners January 10, 2025 20:10
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 10, 2025
SafeDeleteModel(
name="AlertRuleActivations", deletion_action=DeletionAction.MOVE_TO_PENDING
),
]
Copy link
Member Author

Choose a reason for hiding this comment

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

Removing the models also generated this:

        migrations.RemoveField(
            model_name="alertruleactivations",
            name="alert_rule",
        ),
        migrations.RemoveField(
            model_name="alertruleactivations",
            name="query_subscription",
        ),

but I think this has happened in the past and we removed it without error. I was able to run the migration locally fine.

Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/0813_rm_alertruleactivations.py ()

--
-- Alter field alert_rule on alertruleactivationcondition
--
SET CONSTRAINTS "sentry_alertruleacti_alert_rule_id_8373d2c0_fk_sentry_al" IMMEDIATE; ALTER TABLE "sentry_alertruleactivationcondition" DROP CONSTRAINT "sentry_alertruleacti_alert_rule_id_8373d2c0_fk_sentry_al";
--
-- Alter field alert_rule on alertruleactivations
--
SET CONSTRAINTS "sentry_alertruleacti_alert_rule_id_772efdf6_fk_sentry_al" IMMEDIATE; ALTER TABLE "sentry_alertruleactivations" DROP CONSTRAINT "sentry_alertruleacti_alert_rule_id_772efdf6_fk_sentry_al";
--
-- Alter field query_subscription on alertruleactivations
--
SET CONSTRAINTS "sentry_alertruleacti_query_subscription_i_d1458737_fk_sentry_qu" IMMEDIATE; ALTER TABLE "sentry_alertruleactivations" DROP CONSTRAINT "sentry_alertruleacti_query_subscription_i_d1458737_fk_sentry_qu";
--
-- Moved model AlertRuleActivationCondition to pending deletion state
--
-- (no-op)
--
-- Moved model AlertRuleActivations to pending deletion state
--
-- (no-op)

Copy link
Member

@wedamija wedamija left a comment

Choose a reason for hiding this comment

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

This lgtm, will we also write a cleanup script to remove any of these old alerts?

Copy link

codecov bot commented Jan 10, 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   #83255      +/-   ##
==========================================
- Coverage   87.55%   87.54%   -0.02%     
==========================================
  Files        9470     9393      -77     
  Lines      537266   536812     -454     
  Branches    21148    21148              
==========================================
- Hits       470379   469927     -452     
+ Misses      66529    66527       -2     
  Partials      358      358              

@ceorourke
Copy link
Member Author

This lgtm, will we also write a cleanup script to remove any of these old alerts?

There are very few - a handful that have a snapshot status and 5 in sentry orgs that I for some reason can't pull up. Even if there were more I don't think we need to worry about cleaning them up since we will simply not migrate them to the new ACI tables.

@@ -31,6 +33,7 @@ def setup_before_migration(self, app):
GroupInbox.objects.create(group=self.ignored_group, reason=GroupInboxReason.NEW.value)
GroupInbox.objects.create(group=self.unresolved_group, reason=GroupInboxReason.NEW.value)

@pytest.mark.skip(reason="unneeded")
Copy link
Member Author

Choose a reason for hiding this comment

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

maybe I can just fully delete this, I don't think we need old migrations tests do we?

@wedamija
Copy link
Member

wedamija commented Jan 10, 2025

This lgtm, will we also write a cleanup script to remove any of these old alerts?

There are very few - a handful that have a snapshot status and 5 in sentry orgs that I for some reason can't pull up. Even if there were more I don't think we need to worry about cleaning them up since we will simply not migrate them to the new ACI tables.

Good point, no need to clean up old data in these tables at all

@ceorourke ceorourke merged commit d8966ed into master Jan 10, 2025
49 checks passed
@ceorourke ceorourke deleted the ceorourke/rm-activations-models branch January 10, 2025 22:40
@ceorourke ceorourke added the Trigger: Revert Add to a merged PR to revert it (skips CI) label Jan 10, 2025
@getsentry-bot
Copy link
Contributor

PR reverted: 0123b4a

getsentry-bot added a commit that referenced this pull request Jan 10, 2025
ceorourke added a commit that referenced this pull request Jan 14, 2025
Final follow up to #83255 to
actually remove the models now
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 Trigger: Revert Add to a merged PR to revert it (skips CI)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants