Log a message with a traceback immediately when an exception is caught that fails a test or job.

Right now, when tests or jobs fail, we execute various actions before providing any indication of the failure.  Such actions include post-test cleanup, post-iteration sysinfo collection, post-job crashinfo collection, etc.  The exception traceback can be separated from the immediately preceding line by hundreds of lines of unrelated logging output.  Of course the traceback shows you exactly where the exception originated, but this separation in the logs makes debugging a royal pain.

With this change, whenever such a test- or job-ending exception is caught, on the client or the server, we *immediately* log a message with a traceback.  We then carry on with the usual activities and eventually log the traceback again when we're recording failure.  But the first log should make debugging easier and make things more obvious for new and experienced users alike.

Signed-off-by: Steve Howard <[email protected]>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@3852 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/server_job.py b/server/server_job.py
index 2f74b5e..3feb4bf 100755
--- a/server/server_job.py
+++ b/server/server_job.py
@@ -452,10 +452,13 @@
         collect_crashinfo = True
         temp_control_file_dir = None
         try:
-            if install_before and machines:
-                self._execute_code(INSTALL_CONTROL_FILE, namespace)
+            try:
+                if install_before and machines:
+                    self._execute_code(INSTALL_CONTROL_FILE, namespace)
 
-            if not only_collect_crashinfo:
+                if only_collect_crashinfo:
+                    return
+
                 # determine the dir to write the control files to
                 cfd_specified = (control_file_dir
                                  and control_file_dir is not self.USE_TEMP_DIR)
@@ -482,6 +485,13 @@
 
                 # no error occured, so we don't need to collect crashinfo
                 collect_crashinfo = False
+            except:
+                try:
+                    logging.exception(
+                            'Exception escaped control file, job aborting:')
+                except:
+                    pass # don't let logging exceptions here interfere
+                raise
         finally:
             if temp_control_file_dir:
                 # Clean up temp directory used for copies of the control files