← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/launchpad/db-bug-650877 into lp:launchpad

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/db-bug-650877 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers): code


= Bug 650877 =

We've been having the devil of a time performing quality assurance on our build-farm work.  Only on staging can we do proper end-to-end testing, but when something doesn't work, it's very hard to find out whether staging is functional, whether all the required cron jobs have run, and if there was any error output at all, where it is & when it will show up where we can see it.

This branch adds a bit of logging so that we can request meaningful debug runs when needed.  There are no functional changes, and at the normal "info" log level the only new messages will be:

 * Error messages when scheduling a translation templates build fails.

 * An informational message saying that a translation templates build is being requested.

To exercise the new code, run
{{{
./bin/test -vvc lp.translations.tests.test_translationtemplatesbuild
}}}


No lint,

Jeroen
-- 
https://code.launchpad.net/~jtv/launchpad/db-bug-650877/+merge/37565
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/launchpad/db-bug-650877 into lp:launchpad.
=== modified file 'lib/lp/translations/model/translationtemplatesbuildjob.py'
--- lib/lp/translations/model/translationtemplatesbuildjob.py	2010-09-14 11:11:56 +0000
+++ lib/lp/translations/model/translationtemplatesbuildjob.py	2010-10-05 07:43:44 +0000
@@ -8,6 +8,7 @@
     ]
 
 from datetime import timedelta
+import logging
 import re
 
 from storm.store import Store
@@ -114,27 +115,37 @@
         return is_intltool_structure(bzr_branch.basis_tree())
 
     @classmethod
-    def generatesTemplates(cls, branch):
+    def generatesTemplates(cls, branch, logger=None):
         """See `ITranslationTemplatesBuildJobSource`."""
         if branch.private:
             # We don't support generating template from private branches
             # at the moment.
+            if logger is not None:
+                logger.debug("Branch %s is private." % branch.unique_name)
             return False
 
         utility = getUtility(IRosettaUploadJobSource)
         if not utility.providesTranslationFiles(branch):
             # Nobody asked for templates generated from this branch.
+            if logger is not None:
+                logger.debug(
+                    "No templates requested for branch %s." %
+                    branch.unique_name)
             return False
 
         if not cls._hasPotteryCompatibleSetup(branch):
             # Nothing we could do with this branch if we wanted to.
+            if logger is not None:
+                logger.debug(
+                    "Branch %s is not pottery-compatible." %
+                    branch.unique_name)
             return False
 
         # Yay!  We made it.
         return True
 
     @classmethod
-    def create(cls, branch):
+    def create(cls, branch, logger=None):
         """See `ITranslationTemplatesBuildJobSource`."""
         # XXX Danilo Segan bug=580429: we hard-code processor to the Ubuntu
         # default processor architecture.  This stops the buildfarm from
@@ -145,8 +156,15 @@
             BuildFarmJobType.TRANSLATIONTEMPLATESBUILD, processor=processor)
         build = getUtility(ITranslationTemplatesBuildSource).create(
             build_farm_job, branch)
+        if logger is not None:
+            logger.debug(
+                "Made BuildFarmJob %s, TranslationTemplatesBuild %s." % (
+                    build_farm_job.id, build.id))
 
         specific_job = build.makeJob()
+        if logger is not None:
+            logger.debug("Made %s." % specific_job)
+
         duration_estimate = cls.duration_estimate
 
         build_queue_entry = BuildQueue(
@@ -155,6 +173,9 @@
             job=specific_job.job, processor=processor)
         IMasterStore(BuildQueue).add(build_queue_entry)
 
+        if logger is not None:
+            logger.debug("Made BuildQueue %s." % build_queue_entry.id)
+
         return specific_job
 
     @classmethod
@@ -167,13 +188,22 @@
     @classmethod
     def scheduleTranslationTemplatesBuild(cls, branch):
         """See `ITranslationTemplatesBuildJobSource`."""
+        logger = logging.getLogger('translation-templates-build')
         if not config.rosetta.generate_templates:
             # This feature is disabled by default.
+            logging.debug("Templates generation is disabled.")
             return
 
-        if cls.generatesTemplates(branch):
-            # This branch is used for generating templates.
-            cls.create(branch)
+        try:
+            if cls.generatesTemplates(branch, logger=logger):
+                # This branch is used for generating templates.
+                logger.info(
+                    "Requesting templates build for branch %s." %
+                    branch.unique_name)
+                cls.create(branch, logger=logger)
+        except Exception, e:
+            logger.error(e)
+            raise
 
     @classmethod
     def getByJob(cls, job):