sanity_check: alert when too many checks fail on a mailbox

This commit is contained in:
Son NK 2020-06-28 11:18:06 +02:00
parent b23259cacd
commit 28da78e75f
1 changed files with 12 additions and 1 deletions

13
cron.py
View File

@ -279,12 +279,23 @@ def sanity_check():
# hack to not query DNS too often
sleep(1)
if not email_domain_can_be_used_as_mailbox(mailbox.email):
LOG.error(
mailbox.nb_failed_checks += 1
# alert if too much fail
if mailbox.nb_failed_checks > 10:
log_func = LOG.error
else:
log_func = LOG.warning
log_func(
"issue with mailbox %s domain. #alias %s, nb email log %s",
mailbox,
mailbox.nb_alias(),
mailbox.nb_email_log(),
)
else: # reset nb check
mailbox.nb_failed_checks = 0
db.session.commit()
for user in User.filter_by(activated=True).all():
if user.email.lower() != user.email: