build-fail-notification: Mail to -factory after 4, dr after 6 weeks
Let's further automate the process of failed packages. Keeping them around serves nobody. So now, we do: * Mail to maintainer after 1 week of failre * Reminder mail after another week * Send a mail to -factory after 2 more weeks (so, total 4 weeks failed) * File a delete request after 6 weeks failed The delete request will then go into the regular delete process, being blocked by potentially other packages depending on it.
This commit is contained in:
parent
72c1e9b445
commit
1eb5d07c09
@ -8,6 +8,7 @@ import osc.conf
|
||||
import xml.etree.ElementTree as ET
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
import cgi
|
||||
import email.utils
|
||||
import logging
|
||||
import argparse
|
||||
@ -72,11 +73,51 @@ broken builds in Tumbleweed. You receive this mail because you are
|
||||
marked as maintainer for the above mentioned package (or project
|
||||
maintainer if the package has no explicit maintainer assigned)
|
||||
|
||||
Kind regards,
|
||||
%(sender)s
|
||||
""",
|
||||
u"""Dear Package maintainers and hackers.
|
||||
|
||||
Below package(s) in %(project)s have been failing to build for at
|
||||
least 4 weeks. We tried to send out notifications to the
|
||||
configured bugowner/maintainers of the package(s), but so far no
|
||||
fix has been submitted. This probably means that the
|
||||
maintainer/bugowner did not yet find the time to look into the
|
||||
matter and he/she would certainly appreciate help to get this
|
||||
sorted.
|
||||
|
||||
""",
|
||||
u"""
|
||||
Unless somebody is stepping up and submitting fixes, the listed
|
||||
package(s) are going to be removed from %(project)s.
|
||||
|
||||
Kind regards,
|
||||
%(sender)s
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def SendMail(logger, project, sender, to, fullname, subject, text):
|
||||
msg = MIMEText(text, _charset='UTF-8')
|
||||
msg['Subject'] = subject
|
||||
msg['To'] = email.utils.formataddr((to, fullname))
|
||||
msg['From'] = sender
|
||||
msg['Date'] = email.utils.formatdate()
|
||||
msg['Message-ID'] = email.utils.make_msgid()
|
||||
msg.add_header('Precedence', 'bulk')
|
||||
msg.add_header('X-Mailer', '%s - Failure Notification' % project)
|
||||
logger.info("%s: %s", msg['To'], msg['Subject'])
|
||||
if args.dry:
|
||||
logger.debug(msg.as_string())
|
||||
else:
|
||||
try:
|
||||
s = smtplib.SMTP(args.relay)
|
||||
s.sendmail(msg['From'], {msg['To'], sender }, msg.as_string())
|
||||
s.quit()
|
||||
except:
|
||||
logger.error("Failed to send an email to %s (%s)" % (fullname, to))
|
||||
pass
|
||||
|
||||
def main(args):
|
||||
|
||||
# do some work here
|
||||
@ -112,6 +153,7 @@ def main(args):
|
||||
|
||||
Reminded = {}
|
||||
Person = {}
|
||||
ProjectComplainList = []
|
||||
|
||||
# Go through all the failed packages and update the reminder
|
||||
for package in data:
|
||||
@ -157,6 +199,7 @@ def main(args):
|
||||
for userid in maintainers:
|
||||
to = Person[userid][1]
|
||||
fullname = Person[userid][2]
|
||||
subject = '%s - %s - Build fail notification' % (project, package)
|
||||
text = MAIL_TEMPLATES[Reminded[package].remindCount-1] % {
|
||||
'recepient': to,
|
||||
'sender': sender,
|
||||
@ -164,30 +207,32 @@ def main(args):
|
||||
'package' : package,
|
||||
'date': time.ctime(Reminded[package].firstfail),
|
||||
}
|
||||
msg = MIMEText(text, _charset='UTF-8')
|
||||
msg['Subject'] = '%s - %s - Build fail notification' % (project, package)
|
||||
msg['To'] = email.utils.formataddr((to, fullname))
|
||||
msg['From'] = sender
|
||||
msg['Date'] = email.utils.formatdate()
|
||||
msg['Message-ID'] = email.utils.make_msgid()
|
||||
msg.add_header('Precedence', 'bulk')
|
||||
msg.add_header('X-Mailer', '%s - Failure Notification' % project)
|
||||
logger.info("%s: %s", msg['To'], msg['Subject'])
|
||||
if args.dry:
|
||||
logger.debug(msg.as_string())
|
||||
else:
|
||||
try:
|
||||
s = smtplib.SMTP(args.relay)
|
||||
s.sendmail(msg['From'], {msg['To'], sender }, msg.as_string())
|
||||
s.quit()
|
||||
except:
|
||||
logger.error("Failed to send an email to %s (%s)" % (fullname, to))
|
||||
pass
|
||||
SendMail(logger, project, sender, to, fullname, subject, text)
|
||||
elif Reminded[package].remindCount == 4:
|
||||
# Package has failed for 4 weeks - Collect packages to send a mail to openSUSE-factory@ (one mail per day max)
|
||||
ProjectComplainList.append(package)
|
||||
elif Reminded[package].remindCount == 6:
|
||||
# Package failed to build for 6 weeks - file a delete request
|
||||
r = osc.core.Request()
|
||||
r.add_action('delete', tgt_project=project, tgt_package=package)
|
||||
r.description = cgi.escape("[botdel] Package has failed to build for >= 6 weeks")
|
||||
r.create(apiurl)
|
||||
|
||||
elif Reminded[package].remindCount == 3:
|
||||
logger.warning( "Package '%s' has been failing for three weeks - let's create a bug report" % package)
|
||||
else:
|
||||
logger.warning( "Package '%s' is no longer maintained - send a mail to factory maintainers..." % package)
|
||||
if (len(ProjectComplainList)):
|
||||
# At least to report to the project for not building - send a mail to openSUSE-Factory
|
||||
ProjectComplainList.sort()
|
||||
to = 'openSUSE-Factory@opensuse.org'
|
||||
fullname = "openSUSE Factory - Mailing List"
|
||||
subject = "%(project)s - Build fail notification" % {'project': project}
|
||||
text = MAIL_TEMPLATES[2] % {
|
||||
'project': project,
|
||||
'packagelist': ProjectComplainList,
|
||||
'sender': sender,
|
||||
}
|
||||
for pkg in ProjectComplainList:
|
||||
text += "- %s\n" % pkg
|
||||
text += MAIL_TEMPLATE[3]
|
||||
SendMail(logger, project, sender, to, fullname, subject, text)
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='boilerplate python commmand line program')
|
||||
@ -213,4 +258,3 @@ if __name__ == '__main__':
|
||||
logging.basicConfig(level = level)
|
||||
|
||||
sys.exit(main(args))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user