forked from GithubBackups/healthchecks
Fix sendalerts crash loop when encountering a bad cron schedule
This commit is contained in:
parent
ac4f1ca059
commit
4f6f1d9f66
@ -19,7 +19,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Increase the allowable length of Matrix room alias to 100 (#320)
|
- Increase the allowable length of Matrix room alias to 100 (#320)
|
||||||
- Make sure Check.last_ping and Ping.created timestamps match exactly
|
- Make sure Check.last_ping and Ping.created timestamps match exactly
|
||||||
- Don't trigger "down" notifications when changing schedule interactively in web UI
|
- Don't trigger "down" notifications when changing schedule interactively in web UI
|
||||||
|
- Fix sendalerts crash loop when encountering a bad cron schedule
|
||||||
|
|
||||||
## v1.12.0 - 2020-01-02
|
## v1.12.0 - 2020-01-02
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from datetime import timedelta as td
|
||||||
import time
|
import time
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
@ -103,7 +104,16 @@ class Command(BaseCommand):
|
|||||||
old_status = check.status
|
old_status = check.status
|
||||||
q = Check.objects.filter(id=check.id, status=old_status)
|
q = Check.objects.filter(id=check.id, status=old_status)
|
||||||
|
|
||||||
if check.get_status(with_started=False) != "down":
|
try:
|
||||||
|
status = check.get_status(with_started=False)
|
||||||
|
except Exception as e:
|
||||||
|
# Make sure we don't trip on this check again for an hour:
|
||||||
|
# Otherwise sendalerts may end up in a crash loop.
|
||||||
|
q.update(alert_after=now + td(hours=1))
|
||||||
|
# Then re-raise the exception:
|
||||||
|
raise e
|
||||||
|
|
||||||
|
if status != "down":
|
||||||
# It is not down yet. Update alert_after
|
# It is not down yet. Update alert_after
|
||||||
q.update(alert_after=check.going_down_after())
|
q.update(alert_after=check.going_down_after())
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user