To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit ee48faa7 authored by Reto Da Forno's avatar Reto Da Forno
Browse files

prefer mailing list to individual addresses for admin notifications

parent a620860d
......@@ -203,7 +203,7 @@ def main(argv):
cn.commit()
msg = "Found %d stuck tests in the database (IDs: %s). Test status set to 'failed'." % (len(rs), ", ".join(testids))
logger.info(msg)
emails = flocklab.get_admin_emails(cur)
emails = flocklab.get_admin_emails()
if emails != flocklab.FAILED:
flocklab.send_mail(subject="[FlockLab Cleaner]", message=msg, recipients=emails)
......@@ -251,7 +251,7 @@ def main(argv):
if len(pids) > 0:
msg = "%d stuck threads terminated (PIDs: %s)" % (len(pids), ", ".join(pids))
logger.info(msg)
emails = flocklab.get_admin_emails(cur)
emails = flocklab.get_admin_emails()
if emails != flocklab.FAILED:
flocklab.send_mail(subject="[FlockLab Cleaner]", message=msg, recipients=emails)
else:
......@@ -284,7 +284,7 @@ def main(argv):
except:
msg = "Encountered error: %s: %s\n%s" % (str(sys.exc_info()[0]), str(sys.exc_info()[1]), traceback.format_exc())
logger.error(msg)
emails = flocklab.get_admin_emails(cur)
emails = flocklab.get_admin_emails()
msg = "%s on server %s encountered error:\n\n%s" % (__file__, os.uname()[1], msg)
flocklab.send_mail(subject="[FlockLab Cleaner]", message=msg, recipients=emails)
finally:
......
......@@ -164,7 +164,7 @@ Yours faithfully,\nthe FlockLab server"""
if ret != 0:
msg = "Could not send Email to %s. Function returned %d" % (owneremail, ret)
logger.error(msg)
emails = flocklab.get_admin_emails(cur)
emails = flocklab.get_admin_emails()
msg = "%s on server %s encountered error:\n\n%s" % (__file__, os.uname()[1], msg)
flocklab.send_mail(subject="[FlockLab RetentionCleaner]", message=msg, recipients=emails)
continue
......@@ -208,7 +208,7 @@ Yours faithfully,\nthe FlockLab server"""
if ret != 0:
msg = "Could not send Email to %s. Function returned %d" % (owneremail, ret)
logger.error(msg)
emails = flocklab.get_admin_emails(cur)
emails = flocklab.get_admin_emails()
msg = "%s on server %s encountered error:\n\n%s" % (__file__, os.uname()[1], msg)
flocklab.send_mail(subject="[FlockLab RetentionCleaner]", message=msg, recipients=emails)
continue
......@@ -226,7 +226,7 @@ Yours faithfully,\nthe FlockLab server"""
except:
msg = "Encountered error: %s: %s\n%s" % (str(sys.exc_info()[0]), str(sys.exc_info()[1]), traceback.format_exc())
logger.error(msg)
emails = flocklab.get_admin_emails(cur)
emails = flocklab.get_admin_emails()
msg = "%s on server %s encountered error:\n\n%s" % (__file__, os.uname()[1], msg)
flocklab.send_mail(subject="[FlockLab RetentionCleaner]", message=msg, recipients=emails)
finally:
......
......@@ -340,7 +340,7 @@ def main(argv):
except:
logger.error("Could not connect to database")
raise
emails = flocklab.get_admin_emails(cur)
emails = flocklab.get_admin_emails()
flocklab.send_mail(subject="[FlockLab Slot Updater]", message=msg, recipients=emails)
cur.close()
cn.close()
......
......@@ -232,17 +232,20 @@ function check_imageid($imageid, $userid) {
##############################################################################
*/
function get_admin_emails() {
$db = db_connect();
$sql = "SELECT `email`
FROM tbl_serv_users
WHERE `role` = 'admin'";
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get admin emails from database because: ' . mysqli_error($db));
$admins = Array();
while ($row=mysqli_fetch_array($rs)) {
array_push($admins, $row['email']);
if (isset($CONFIG['email']['admin_email'])) {
array_push($admins, trim($CONFIG['email']['admin_email']));
} else {
$db = db_connect();
$sql = "SELECT `email`
FROM tbl_serv_users
WHERE `role` = 'admin'";
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get admin emails from database because: ' . mysqli_error($db));
while ($row=mysqli_fetch_array($rs)) {
array_push($admins, $row['email']);
}
mysqli_close($db);
}
mysqli_close($db);
return $admins;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment