From f327722e06f450b698de6654e54a63e907bc20bd Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior Date: Thu, 28 Sep 2017 15:22:42 -0400 Subject: [PATCH] Implement threading for breakage messages. --- master.cfg | 92 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 75 insertions(+), 17 deletions(-) diff --git a/master.cfg b/master.cfg index db5ec63..a137c49 100644 --- a/master.cfg +++ b/master.cfg @@ -219,6 +219,62 @@ def SendRootMessageGDBTesters (branch, change, rev, def make_breakage_lockfile_name (branch, builder): return "/tmp/gdb-buildbot-breakage-report-%s-%s" % (branch, builder) +def make_breakage_root_message_id_filename (rev, branch): + return "/tmp/gdb-buildbot-message-id-breakage-%s-%s" % (rev, branch) + +def make_breakage_root_message_id (rev, branch): + mid_file = make_breakage_root_message_id_filename (rev, branch) + mid = "%s-%s-breakage@gdb-build" % (rev, branch) + if not os.path.exists (mid_file): + mf = open (mid_file, 'w') + mf.write (mid) + mf.close () + return mid + +def SendRootBreakageMessage (builder, branch, change): + """Send the root message that will contain the breakage emails.""" + global GDB_MAIL_FROM + + rev = change.revision + + if os.path.exists (make_breakage_root_message_id_filename (rev, branch)): + # Already sent + return + + message_id = make_breakage_root_message_id (rev, branch) + to = change.who.encode ('ascii', 'ignore').decode ('ascii') + to += ", gdb-patches@sourceware.org" + to_list = [ to ] + to_list.append ('gdb-patches@sourceware.org') + title = change.comments.split ('\n')[0] + + sbj = 'Oh dear. I regret to inform you that commit %s might be unfortunate' % change.revision + if branch != 'master': + sbj += ' [%s]' % branch + + text = "My lords, ladies, gentlemen, members of the public.\n\n" + text += "It is a matter of great regret and sadness to inform you that commit:\n\n" + text += "\t%s\n" % title + text += "\t%s\n\n" % rev + text += "might have made GDB unwell. Since I am just your Butler BuildBot,\n" + text += "I kindly ask that a human superior officer double-check this.\n\n" + text += "Please note that if you are reading this message on gdb-patches, there might\n" + text += "be other builders broken.\n\n" + text += "You can find more details about the unfortunate breakage in the next messages.\n\n" + text += "Cheers,\n\n" + text += "Your GDB BuildBot." + + mail = MIMEText (text) + mail['Subject'] = sbj + mail['From'] = 'gdb-buildbot@sergiodj.net' + mail['To'] = to + mail['Message-Id'] = message_id + + s = smtplib.SMTP ('localhost') + s.sendmail (GDB_MAIL_FROM, to_list, mail.as_string ()) + s.quit () + + def SendAuthorBreakageMessage (name, branch, change, text_prepend): """Send a message to the author of the commit if it broke GDB. @@ -237,39 +293,35 @@ subsequent commits are made after X, by different people.""" # This file will be cleaned the next time we run # MessageGDBTesters, iff the build breakage has been fixed. bf = open (lockfile, 'w') - bf.write ("Commit that caused the breakage: %s\n" % change.revision) + bf.write ("Commit: %s\n" % change.revision) bf.close () + SendRootBreakageMessage (name, branch, change) + root_message_id = make_breakage_root_message_id (rev, branch) + rev = change.revision to = change.who.encode ('ascii', 'ignore').decode ('ascii') + to += ", gdb-patches@sourceware.org" to_list = [ to ] + to_list.append ('gdb-patches@sourceware.org') title = change.comments.split ('\n')[0] - sbj = 'Oh dear. I regret to inform you that commit %s might be unfortunate' % change.revision + sbj = 'Breakage on builder %s, revision %s' % (name, rev) if branch != 'master': sbj += ' [%s]' % branch - text = "My lords, ladies, gentlemen, members of the public.\n\n" - text += "It is a matter of great regret and sadness to inform you that commit:\n\n" - text += "\t%s\n" % title - text += "\t%s\n\n" % rev - text += "might have made GDB unwell. Since I am just your Butler BuildBot,\n" - text += "I kindly ask that a human superior officer double-check this.\n\n" - text += "Please note that if you are reading this message on gdb-patches, there might\n" - text += "be other builders broken.\n\n" - text += "You can find more details about the unfortunate breakage below.\n\n" - text += "Cheers,\n\n" - text += "Your GDB BuildBot.\n\n" + text += "Unfortunately it seems that there is a breakage on GDB.\n\n" + text += "Commit title: '%s'\n" % title + text += "Revision: %s\n\n" %rev + text += "You can find more details below:\n\n" text += "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n\n" - text += "\n" + text_prepend + text += text_prepend mail = MIMEText (text) mail['Subject'] = sbj mail['From'] = 'gdb-buildbot@sergiodj.net' - to += ", gdb-patches@sourceware.org" - to_list.append ('gdb-patches@sourceware.org') mail['To'] = to - mail['Reply-To'] = 'gdb-patches@sourceware.org' + mail['In-Reply-To'] = root_message_id s = smtplib.SMTP ('localhost') s.sendmail (GDB_MAIL_FROM, to_list, mail.as_string ()) @@ -428,9 +480,15 @@ send to the gdb-testers mailing list.""" # There is no build breakage anymore! Yay! Now, let's see if # we need to clean up any lock file from previous breaks. lockfile = make_breakage_lockfile_name (branch, name) + with open (lockfile, 'r') as f: + rev_broke = f.readline ().lstrip ("Commit: ") + mid_file = make_breakage_root_message_id_filename (rev_broke, branch) if os.path.exists (lockfile): # We need to clean the lockfile. Garbage-collect it here. os.remove (lockfile) + if os.path.exists (mid_file): + # Garbage-collect the Message-Id file + os.remove (mid_file) return { 'body' : text, 'type' : 'plain',