diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 352: fix master file deletion logic

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

Commit Message

Andy Doan July 20, 2012, 10:21 p.m. UTC
------------------------------------------------------------
revno: 352
committer: Andy Doan <andy.doan@linaro.org>
branch nick: lava-dispatcher
timestamp: Fri 2012-07-20 17:18:48 -0500
message:
  fix master file deletion logic
  
  the bugs fixed by the previous commit were causing cache files to not
  get deleted at exit because the exception handler for that path didn't
  have the logic. The only way to delete files was if you got to the logic
  where the master image was launched. This just simplifies things by doing
  an 'atexit' so it won't get skipped
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-07-20 22:17:45 +0000
+++ lava_dispatcher/client/master.py	2012-07-20 22:18:48 +0000
@@ -498,6 +498,7 @@ 
                 boot_tgz, root_tgz = self._generate_tarballs(image_file)
             else:
                 tarball_dir = mkdtemp(dir=LAVA_IMAGE_TMPDIR)
+                atexit.register(shutil.rmtree, tarball_dir)
                 os.chmod(tarball_dir, 0755)
                 lava_cachedir = self.context.lava_cachedir
                 if self.context.job_data.get('health_check', False):
@@ -532,36 +533,33 @@ 
 
         # deploy the boot image and rootfs to target
         logging.info("Booting 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 [
-                LAVA_IMAGE_URL, boot_tarball])
-            root_url = '/'.join(u.strip('/') for u in [
-                LAVA_IMAGE_URL, root_tarball])
-            with self._master_session() as session:
-                self._format_testpartition(session, rootfstype)
-
-                logging.info("Waiting for network to come up")
-                try:
-                    session.wait_network_up()
-                except:
-                    logging.error("Unable to reach LAVA server, check network")
-                    tb = traceback.format_exc()
-                    self.sio.write(tb)
-                    raise CriticalError("Unable to reach LAVA server, check network")
-
-                try:
-                    _deploy_linaro_rootfs(session, root_url)
-                    _deploy_linaro_bootfs(session, boot_url)
-                except:
-                    logging.error("Deployment failed")
-                    tb = traceback.format_exc()
-                    self.sio.write(tb)
-                    raise CriticalError("Deployment failed")
-        finally:
-            shutil.rmtree(os.path.dirname(boot_tgz))
+        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 [
+            LAVA_IMAGE_URL, boot_tarball])
+        root_url = '/'.join(u.strip('/') for u in [
+            LAVA_IMAGE_URL, root_tarball])
+        with self._master_session() as session:
+            self._format_testpartition(session, rootfstype)
+
+            logging.info("Waiting for network to come up")
+            try:
+                session.wait_network_up()
+            except:
+                logging.error("Unable to reach LAVA server, check network")
+                tb = traceback.format_exc()
+                self.sio.write(tb)
+                raise CriticalError("Unable to reach LAVA server, check network")
+
+            try:
+                _deploy_linaro_rootfs(session, root_url)
+                _deploy_linaro_bootfs(session, boot_url)
+            except:
+                logging.error("Deployment failed")
+                tb = traceback.format_exc()
+                self.sio.write(tb)
+                raise CriticalError("Deployment failed")
 
     def deploy_linaro_android(self, boot, system, data, pkg=None, rootfstype='ext4'):
         LAVA_IMAGE_TMPDIR = self.context.lava_image_tmpdir