Browse Source

Fix sendalerts crash loop when encountering a bad cron schedule

pull/328/head
Pēteris Caune 5 years ago
parent
commit
4f6f1d9f66
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
2 changed files with 12 additions and 2 deletions
  1. +1
    -1
      CHANGELOG.md
  2. +11
    -1
      hc/api/management/commands/sendalerts.py

+ 1
- 1
CHANGELOG.md View File

@ -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


+ 11
- 1
hc/api/management/commands/sendalerts.py View File

@ -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…
Cancel
Save