mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-03-15 20:54:53 +00:00
Don't trigger "down" notifications when changing schedule interactively in web UI
This commit is contained in:
parent
6bc4948d00
commit
5d9944873c
3 changed files with 27 additions and 1 deletions
|
@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
|
|||
### Bug Fixes
|
||||
- Increase the allowable length of Matrix room alias to 100 (#320)
|
||||
- Make sure Check.last_ping and Ping.created timestamps match exactly
|
||||
- Don't trigger "down" notifications when changing schedule interactively in web UI
|
||||
|
||||
|
||||
## v1.12.0 - 2020-01-02
|
||||
|
|
|
@ -31,7 +31,7 @@ class UpdateTimeoutTestCase(BaseTestCase):
|
|||
expected_aa = self.check.last_ping + td(seconds=3600 + 60)
|
||||
self.assertEqual(self.check.alert_after, expected_aa)
|
||||
|
||||
def test_it_does_not_update_status(self):
|
||||
def test_it_does_not_update_status_to_up(self):
|
||||
self.check.last_ping = timezone.now() - td(days=2)
|
||||
self.check.status = "down"
|
||||
self.check.save()
|
||||
|
@ -45,6 +45,22 @@ class UpdateTimeoutTestCase(BaseTestCase):
|
|||
self.check.refresh_from_db()
|
||||
self.assertEqual(self.check.status, "down")
|
||||
|
||||
def test_it_updates_status_to_down(self):
|
||||
self.check.last_ping = timezone.now() - td(hours=1)
|
||||
self.check.status = "up"
|
||||
self.check.alert_after = self.check.going_down_after()
|
||||
self.check.save()
|
||||
|
||||
# 1 + 1 minute:
|
||||
payload = {"kind": "simple", "timeout": 60, "grace": 60}
|
||||
|
||||
self.client.login(username="alice@example.org", password="password")
|
||||
self.client.post(self.url, data=payload)
|
||||
|
||||
self.check.refresh_from_db()
|
||||
self.assertEqual(self.check.status, "down")
|
||||
self.assertIsNone(self.check.alert_after)
|
||||
|
||||
def test_it_saves_cron_expression(self):
|
||||
payload = {"kind": "cron", "schedule": "5 * * * *", "tz": "UTC", "grace": 60}
|
||||
|
||||
|
|
|
@ -377,6 +377,15 @@ def update_timeout(request, code):
|
|||
check.grace = td(minutes=form.cleaned_data["grace"])
|
||||
|
||||
check.alert_after = check.going_down_after()
|
||||
if check.status == "up" and check.alert_after < timezone.now():
|
||||
# Checks can flip from "up" to "down" state as a result of changing check's
|
||||
# schedule. We don't want to send notifications when changing schedule
|
||||
# interactively in the web UI. So we update the `alert_after` and `status`
|
||||
# fields here the same way as `sendalerts` would do, but without sending
|
||||
# an actual alert:
|
||||
check.alert_after = None
|
||||
check.status = "down"
|
||||
|
||||
check.save()
|
||||
|
||||
if "/details/" in request.META.get("HTTP_REFERER", ""):
|
||||
|
|
Loading…
Reference in a new issue