diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 192: delete temporary images when boot_master_image fails during deployment

Message ID 20120115233913.28618.6238.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Michael-Doyle Hudson Jan. 15, 2012, 11:39 p.m. UTC
Merge authors:
  Michael Hudson-Doyle (mwhudson)
Related merge proposals:
  https://code.launchpad.net/~mwhudson/lava-dispatcher/delete-images-when-boot_master_image-fails/+merge/88447
  proposed by: Michael Hudson-Doyle (mwhudson)
  review: Approve - Zygmunt Krynicki (zkrynicki)
------------------------------------------------------------
revno: 192 [merge]
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Mon 2012-01-16 12:37:30 +1300
message:
  delete temporary images when boot_master_image fails during deployment
modified:
  lava_dispatcher/client/master.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/client/master.py'
--- lava_dispatcher/client/master.py	2012-01-13 03:52:53 +0000
+++ lava_dispatcher/client/master.py	2012-01-15 23:37:30 +0000
@@ -259,8 +259,8 @@ 
             self.sio.write(tb)
             raise CriticalError("Deployment tarballs preparation failed")
         logging.info("Booting master image")
-        self.boot_master_image()
         try:
+            self.boot_master_image()
             boot_tarball = boot_tgz.replace(LAVA_IMAGE_TMPDIR, '')
             root_tarball = root_tgz.replace(LAVA_IMAGE_TMPDIR, '')
             boot_url = '/'.join(u.strip('/') for u in [
@@ -296,53 +296,53 @@ 
         logging.info("  system: %s" % system)
         logging.info("  data: %s" % data)
         logging.info("Boot master image")
-        self.boot_master_image()
-
-        with self._master_session() as session:
-            logging.info("Waiting for network to come up...")
-            try:
-                session.wait_network_up()
-            except:
-                tb = traceback.format_exc()
-                self.sio.write(tb)
-                raise CriticalError("Unable to reach LAVA server, check network")
-
-            try:
-                boot_tbz2, system_tbz2, data_tbz2, pkg_tbz2 = \
-                    self._download_tarballs(boot, system, data, pkg, use_cache)
-            except:
-                tb = traceback.format_exc()
-                self.sio.write(tb)
-                raise CriticalError("Unable to download artifacts for deployment")
-
-            boot_tarball = boot_tbz2.replace(LAVA_IMAGE_TMPDIR, '')
-            system_tarball = system_tbz2.replace(LAVA_IMAGE_TMPDIR, '')
-            #data_tarball = data_tbz2.replace(LAVA_IMAGE_TMPDIR, '')
-
-            boot_url = '/'.join(u.strip('/') for u in [
-                LAVA_IMAGE_URL, boot_tarball])
-            system_url = '/'.join(u.strip('/') for u in [
-                LAVA_IMAGE_URL, system_tarball])
-            #data_url = '/'.join(u.strip('/') for u in [
-            #    LAVA_IMAGE_URL, data_tarball])
-            if pkg_tbz2:
-                pkg_tarball = pkg_tbz2.replace(LAVA_IMAGE_TMPDIR, '')
-                pkg_url = '/'.join(u.strip('/') for u in [
-                    LAVA_IMAGE_URL, pkg_tarball])
-            else:
-                pkg_url = None
-
-            try:
-                _deploy_linaro_android_testboot(session, boot_url, pkg_url)
-                _deploy_linaro_android_testrootfs(session, system_url, rootfstype)
-                _purge_linaro_android_sdcard(session)
-            except:
-                tb = traceback.format_exc()
-                self.sio.write(tb)
-                raise CriticalError("Android deployment failed")
-            finally:
-                shutil.rmtree(self.tarball_dir)
-                logging.info("Android image deployment exiting")
+        try:
+            self.boot_master_image()
+            with self._master_session() as session:
+                logging.info("Waiting for network to come up...")
+                try:
+                    session.wait_network_up()
+                except:
+                    tb = traceback.format_exc()
+                    self.sio.write(tb)
+                    raise CriticalError("Unable to reach LAVA server, check network")
+
+                try:
+                    boot_tbz2, system_tbz2, data_tbz2, pkg_tbz2 = \
+                        self._download_tarballs(boot, system, data, pkg, use_cache)
+                except:
+                    tb = traceback.format_exc()
+                    self.sio.write(tb)
+                    raise CriticalError("Unable to download artifacts for deployment")
+
+                boot_tarball = boot_tbz2.replace(LAVA_IMAGE_TMPDIR, '')
+                system_tarball = system_tbz2.replace(LAVA_IMAGE_TMPDIR, '')
+                #data_tarball = data_tbz2.replace(LAVA_IMAGE_TMPDIR, '')
+
+                boot_url = '/'.join(u.strip('/') for u in [
+                    LAVA_IMAGE_URL, boot_tarball])
+                system_url = '/'.join(u.strip('/') for u in [
+                    LAVA_IMAGE_URL, system_tarball])
+                #data_url = '/'.join(u.strip('/') for u in [
+                #    LAVA_IMAGE_URL, data_tarball])
+                if pkg_tbz2:
+                    pkg_tarball = pkg_tbz2.replace(LAVA_IMAGE_TMPDIR, '')
+                    pkg_url = '/'.join(u.strip('/') for u in [
+                        LAVA_IMAGE_URL, pkg_tarball])
+                else:
+                    pkg_url = None
+
+                try:
+                    _deploy_linaro_android_testboot(session, boot_url, pkg_url)
+                    _deploy_linaro_android_testrootfs(session, system_url, rootfstype)
+                    _purge_linaro_android_sdcard(session)
+                except:
+                    tb = traceback.format_exc()
+                    self.sio.write(tb)
+                    raise CriticalError("Android deployment failed")
+        finally:
+            shutil.rmtree(self.tarball_dir)
+            logging.info("Android image deployment exiting")
 
     def _download_tarballs(self, boot_url, system_url, data_url, pkg_url=None,
             use_cache=True):