-
Notifications
You must be signed in to change notification settings - Fork 297
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
remove deprecated heartbeat_heartbeat table/model #2534
Conversation
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"),) |
There was a problem hiding this comment.
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.
engine/apps/heartbeat/tasks.py
Outdated
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
voila
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
55b3f21
to
fd9c80e
Compare
710b7b5
to
7969606
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo fixes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo fixes
# 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).
What this PR does
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).