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

remove deprecated heartbeat_heartbeat table/model #2534

Merged
merged 4 commits into from
Jul 17, 2023

Conversation

joeyorlando
Copy link
Contributor

@joeyorlando joeyorlando commented Jul 14, 2023

What this PR does

  • Remove heartbeat_heartbeat table. This model/table does not seems to be deprecated/used anywhere (no data in this in production/staging; see more comments in the code about this).

@joeyorlando joeyorlando requested a review from a team as a code owner July 14, 2023 12:17
@joeyorlando joeyorlando requested review from a team July 14, 2023 12:17
@joeyorlando joeyorlando added the pr:no public docs Added to a PR that does not require public documentation updates label Jul 14, 2023
@joeyorlando joeyorlando changed the title fix heartbeat icon on integration page fix the ability to create/update an integration heartbeat Jul 14, 2023
Comment on lines -100 to -154
class HeartBeat(BaseHeartBeat):
"""
HeartBeat Integration itself
"""

alert_receive_channel = models.ForeignKey(
"alerts.AlertReceiveChannel", on_delete=models.CASCADE, related_name="heartbeats"
)

message = models.TextField(default="")
title = models.TextField(default="HeartBeat Title")
link = models.URLField(max_length=500, default=None, null=True)
user_defined_id = models.CharField(default="default", max_length=100)

def on_heartbeat_restored(self):
create_alert.apply_async(
kwargs={
"title": "[OK] " + self.title,
"message": self.title,
"image_url": None,
"link_to_upstream_details": self.link,
"alert_receive_channel_pk": self.alert_receive_channel.pk,
"integration_unique_data": {},
"raw_request_data": {
"is_resolve": True,
"id": self.pk,
"user_defined_id": self.user_defined_id,
},
},
)

def on_heartbeat_expired(self):
create_alert.apply_async(
kwargs={
"title": "[EXPIRED] " + self.title,
"message": self.message
+ "\nCreated: {}\nExpires: {}\nLast HeartBeat: {}".format(
self.created_at,
self.expiration_time,
self.last_checkup_task_time,
),
"image_url": None,
"link_to_upstream_details": self.link,
"alert_receive_channel_pk": self.alert_receive_channel.pk,
"integration_unique_data": {},
"raw_request_data": {
"is_resolve": False,
"id": self.pk,
"user_defined_id": self.user_defined_id,
},
}
)

class Meta:
unique_together = (("alert_receive_channel", "user_defined_id"),)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this model does not appear to be used anywhere. It's table has zero data in it in our production/staging databases. Lets remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the two deleted tasks here iterate over heartbeat.HeartBeat objects, and since there is no data to iterate over, we can remove

@@ -33,7 +32,6 @@
path("grafana_alerting/<str:alert_channel_key>/", GrafanaAlertingAPIView.as_view(), name="grafana_alerting"),
path("alertmanager/<str:alert_channel_key>/", AlertManagerAPIView.as_view(), name="alertmanager"),
path("amazon_sns/<str:alert_channel_key>/", AmazonSNS.as_view(), name="amazon_sns"),
path("heartbeat/<str:alert_channel_key>/", HeartBeatAPIView.as_view(), name="heartbeat"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

there doesn't appear to be any traffic to this endpoint, fairly certain it is safe to remove, alongside the model/table. All new heartbeats appear to be of the IntegrationHeartBeat type

@@ -262,122 +257,6 @@ def post(self, request, *args, **kwargs):
return Response("Ok.")


# TODO: restore HeartBeatAPIView integration or clean it up as it is not used now
Copy link
Contributor Author

Choose a reason for hiding this comment

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

voila

Copy link
Contributor

@matiasb matiasb left a comment

Choose a reason for hiding this comment

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

LGTM

@joeyorlando joeyorlando changed the title fix the ability to create/update an integration heartbeat remove deprecated heartbeat_heartbeat table/model Jul 15, 2023
@joeyorlando joeyorlando force-pushed the jorlando/fix-heartbeat-icon-on-integration-page branch from 55b3f21 to fd9c80e Compare July 15, 2023 14:16
@joeyorlando joeyorlando force-pushed the jorlando/fix-heartbeat-icon-on-integration-page branch from 710b7b5 to 7969606 Compare July 15, 2023 14:22
Copy link
Contributor Author

Choose a reason for hiding this comment

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

typo fixes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

typo fixes

@joeyorlando joeyorlando merged commit 63ac097 into dev Jul 17, 2023
@joeyorlando joeyorlando deleted the jorlando/fix-heartbeat-icon-on-integration-page branch July 17, 2023 05:38
brojd pushed a commit that referenced this pull request Sep 18, 2024
# What this PR does

- Remove `heartbeat_heartbeat` table. This model/table does not seems to
be deprecated/used anywhere (no data in this in production/staging; see
more comments in the code about this).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants