Repository: fedora-infra/bodhi

Issue:
Log a summary instead at the end of the mash
Right now it just says "push complete" https://github.com/fedora-infra/bodhi/blob/develop/bodhi/consumers/masher.py#L207

but... it would be cool if it could print out some sort of summary of all the branches it tried, whether they succeeded or failed, and if any updates were ejected for any of those.  Something so that the operator can know if they need to do anything special or not.



Discussion:
@ralphbean I would like to look into this :) More hints will be required


Resolving patch:
diff --git a/bodhi/consumers/masher.py b/bodhi/consumers/masher.py
--- a/bodhi/consumers/masher.py
+++ b/bodhi/consumers/masher.py
@@ -187,6 +187,7 @@ def work(self, msg):
             releases = self.organize_updates(session, body)
             batches = self.prioritize_updates(releases)
 
+        results = []
         # Important repos first, then normal
         for batch in batches:
             # Stable first, then testing
@@ -203,8 +204,11 @@ def work(self, msg):
                         thread.start()
                 for thread in threads:
                     thread.join()
+                results.extend([thread.results() for thread in threads])
 
-        self.log.info('Push complete!')
+        self.log.info('Push complete!  Summary follows:')
+        for result in results:
+            self.log.info(result)
 
     def organize_updates(self, session, body):
         # {Release: {UpdateRequest: [Update,]}}
@@ -242,6 +246,7 @@ def __init__(self, release, request, updates, log, db_factory,
             'updates': updates,
             'completed_repos': []
         }
+        self.success = False
 
     def run(self):
         try:
@@ -252,6 +257,22 @@ def run(self):
         except:
             self.log.exception('MasherThread failed. Transaction rolled back.')
 
+    def results(self):
+        attrs = ['name', 'success']
+        yield "  name:  %(name)-20s  success:  %(success)s" % dict(
+            zip(attrs, [getattr(self, attr, 'Undefined') for attr in attrs])
+        )
+        ## If we wanted to include more info in the summary at the end, we
+        ## could do this.. but I bet it would be so spammy that it would ruin
+        ## the effect of a summary.  It would scroll longer than one page, and
+        ## you wouldn't be able to see the success/failure status of all the
+        ## different threads all in one glance.
+        #for tag, nvr in self.add_tags:
+        #    yield "    added tag %(tag)s to %(nvr)s" % dict(tag=tag, nvr=nvr)
+        #for src, dest, nvr in self.add_tags:
+        #    yield "    moved %(nvr)s from %(src)s to %(nvr)s" % dict(
+        #        src=src, dest=dest, nvr=nvr)
+
     def work(self):
         self.koji = buildsys.get_session()
         self.release = self.db.query(Release)\
@@ -282,7 +303,6 @@ def work(self):
             force=True,
         )
 
-        success = False
         try:
             if self.resume:
                 self.load_state()
@@ -351,7 +371,7 @@ def work(self):
             # Email updates-testing digest
             self.send_testing_digest()
 
-            success = True
+            self.success = True
             self.remove_state()
             self.unlock_updates()
             self.check_all_karma_thresholds()
@@ -360,7 +380,7 @@ def work(self):
             self.save_state()
             raise
         finally:
-            self.finish(success)
+            self.finish(self.success)
 
     def load_updates(self):
         self.log.debug('Loading updates')


Test patch: