Fix up the sysinfo install procedure to be more transactional. If
the autotest installation fails we want the logger object to remain
uninstalled, with no Host and Autotest objects associated with it.
Whatever caused the install to fail will still fail the sysinfo
collection, but this should at least expose the root cause of the
failure.

Also drops the sysinfo keyval collection from the post-iteration
hook. The post-iteration code doesn't ever generate such a keyval
so this will always fail. It doesn't cause any problems, but it's
pointless noise.

Risk: Low
Visibility: Eliminate an area where the sysinfo collection can
fail with an error that masks the real cause of the failure.

Signed-off-by: John Admanski <[email protected]>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@3650 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/test.py b/server/test.py
index 99f2a74..8fdba9d7 100755
--- a/server/test.py
+++ b/server/test.py
@@ -89,10 +89,21 @@
             from autotest_lib.server import hosts, autotest
             self.host = hosts.create_host(self.job.machines[0],
                                           auto_monitor=False)
-            tmp_dir = self.host.get_tmp_dir(parent="/tmp/sysinfo")
-            self.autotest = autotest.Autotest(self.host)
-            self.autotest.install(autodir=tmp_dir)
-            self.outputdir = self.host.get_tmp_dir()
+            try:
+                tmp_dir = self.host.get_tmp_dir(parent="/tmp/sysinfo")
+                self.autotest = autotest.Autotest(self.host)
+                self.autotest.install(autodir=tmp_dir)
+                self.outputdir = self.host.get_tmp_dir()
+            except:
+                # if installation fails roll back the host
+                try:
+                    self.host.close()
+                except:
+                    logging.exception("Unable to close host %s",
+                                      self.host.hostname)
+                self.host = None
+                self.autotest = None
+                raise
         else:
             host = self.host
 
@@ -182,7 +193,6 @@
 
         # get the new sysinfo state from the client
         self._pull_pickle(host, outputdir)
-        self._pull_sysinfo_keyval(host, outputdir, mytest)
 
 
     @log.log_and_ignore_errors("post-test server sysinfo error:")