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): ...@@ -203,7 +203,7 @@ def main(argv):
cn.commit() cn.commit()
msg = "Found %d stuck tests in the database (IDs: %s). Test status set to 'failed'." % (len(rs), ", ".join(testids)) msg = "Found %d stuck tests in the database (IDs: %s). Test status set to 'failed'." % (len(rs), ", ".join(testids))
logger.info(msg) logger.info(msg)
emails = flocklab.get_admin_emails(cur) emails = flocklab.get_admin_emails()
if emails != flocklab.FAILED: if emails != flocklab.FAILED:
flocklab.send_mail(subject="[FlockLab Cleaner]", message=msg, recipients=emails) flocklab.send_mail(subject="[FlockLab Cleaner]", message=msg, recipients=emails)
...@@ -251,7 +251,7 @@ def main(argv): ...@@ -251,7 +251,7 @@ def main(argv):
if len(pids) > 0: if len(pids) > 0:
msg = "%d stuck threads terminated (PIDs: %s)" % (len(pids), ", ".join(pids)) msg = "%d stuck threads terminated (PIDs: %s)" % (len(pids), ", ".join(pids))
logger.info(msg) logger.info(msg)
emails = flocklab.get_admin_emails(cur) emails = flocklab.get_admin_emails()
if emails != flocklab.FAILED: if emails != flocklab.FAILED:
flocklab.send_mail(subject="[FlockLab Cleaner]", message=msg, recipients=emails) flocklab.send_mail(subject="[FlockLab Cleaner]", message=msg, recipients=emails)
else: else:
...@@ -284,7 +284,7 @@ def main(argv): ...@@ -284,7 +284,7 @@ def main(argv):
except: except:
msg = "Encountered error: %s: %s\n%s" % (str(sys.exc_info()[0]), str(sys.exc_info()[1]), traceback.format_exc()) msg = "Encountered error: %s: %s\n%s" % (str(sys.exc_info()[0]), str(sys.exc_info()[1]), traceback.format_exc())
logger.error(msg) 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) 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) flocklab.send_mail(subject="[FlockLab Cleaner]", message=msg, recipients=emails)
finally: finally:
......
...@@ -164,7 +164,7 @@ Yours faithfully,\nthe FlockLab server""" ...@@ -164,7 +164,7 @@ Yours faithfully,\nthe FlockLab server"""
if ret != 0: if ret != 0:
msg = "Could not send Email to %s. Function returned %d" % (owneremail, ret) msg = "Could not send Email to %s. Function returned %d" % (owneremail, ret)
logger.error(msg) 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) 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) flocklab.send_mail(subject="[FlockLab RetentionCleaner]", message=msg, recipients=emails)
continue continue
...@@ -208,7 +208,7 @@ Yours faithfully,\nthe FlockLab server""" ...@@ -208,7 +208,7 @@ Yours faithfully,\nthe FlockLab server"""
if ret != 0: if ret != 0:
msg = "Could not send Email to %s. Function returned %d" % (owneremail, ret) msg = "Could not send Email to %s. Function returned %d" % (owneremail, ret)
logger.error(msg) 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) 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) flocklab.send_mail(subject="[FlockLab RetentionCleaner]", message=msg, recipients=emails)
continue continue
...@@ -226,7 +226,7 @@ Yours faithfully,\nthe FlockLab server""" ...@@ -226,7 +226,7 @@ Yours faithfully,\nthe FlockLab server"""
except: except:
msg = "Encountered error: %s: %s\n%s" % (str(sys.exc_info()[0]), str(sys.exc_info()[1]), traceback.format_exc()) msg = "Encountered error: %s: %s\n%s" % (str(sys.exc_info()[0]), str(sys.exc_info()[1]), traceback.format_exc())
logger.error(msg) 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) 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) flocklab.send_mail(subject="[FlockLab RetentionCleaner]", message=msg, recipients=emails)
finally: finally:
......
...@@ -340,7 +340,7 @@ def main(argv): ...@@ -340,7 +340,7 @@ def main(argv):
except: except:
logger.error("Could not connect to database") logger.error("Could not connect to database")
raise raise
emails = flocklab.get_admin_emails(cur) emails = flocklab.get_admin_emails()
flocklab.send_mail(subject="[FlockLab Slot Updater]", message=msg, recipients=emails) flocklab.send_mail(subject="[FlockLab Slot Updater]", message=msg, recipients=emails)
cur.close() cur.close()
cn.close() cn.close()
......
...@@ -232,17 +232,20 @@ function check_imageid($imageid, $userid) { ...@@ -232,17 +232,20 @@ function check_imageid($imageid, $userid) {
############################################################################## ##############################################################################
*/ */
function get_admin_emails() { 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(); $admins = Array();
while ($row=mysqli_fetch_array($rs)) { if (isset($CONFIG['email']['admin_email'])) {
array_push($admins, $row['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; 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