[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.45-102-g4c48ac2

Andreas Beckmann debian at abeckmann.de
Fri Aug 3 08:51:40 UTC 2012


The following commit has been merged in the develop branch:
commit 5d8d0db213793c411ce60fccfedf2d7b82906643
Author: Andreas Beckmann <debian at abeckmann.de>
Date:   Thu Jun 21 00:48:52 2012 +0200

    p-s: try to unreserve all reserved logs after interrupt
    
    so other slaves can continue the unfinished work
    
    Signed-off-by: Andreas Beckmann <debian at abeckmann.de>

diff --git a/debian/changelog b/debian/changelog
index 5992ecc..d555dbf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -35,6 +35,7 @@ piuparts (0.46) UNRELEASED; urgency=low
     - Skip connection to master if we have reserved but no submittable logs.
     - Submit finished logs after completing all reserved logs in a section.
     - Send finished logs to master if interrupted with a single Ctrl-C.
+    - Try to unreserve all reserved logs after interrupt.
     - Add SIGHUP handler that triggers flushing finished logs.  Flushing (all
       sections) will be done after the current test has finished.
   * piuparts-report.py:
diff --git a/piuparts-slave.py b/piuparts-slave.py
index f28899b..458588c 100644
--- a/piuparts-slave.py
+++ b/piuparts-slave.py
@@ -254,6 +254,16 @@ class Slave:
         else:
             raise MasterIsCrazy()
 
+    def unreserve(self, filename):
+        basename = os.path.basename(filename)
+        package, rest = basename.split("_", 1)
+        version = rest[:-len(".log")]
+        logging.info("Unreserve: %s %s" % (package, version))
+        self._writeline("unreserve", package, version)
+        line = self._readline()
+        if line != "ok\n":
+            raise MasterNotOK()
+
     def _reserved_filename(self, name, version):
         return os.path.join("reserved",  "%s_%s.log" % (name, version))
 
@@ -390,7 +400,7 @@ class Section:
         return 0
 
 
-    def _talk_to_master(self, fetch=False):
+    def _talk_to_master(self, fetch=False, unreserve=False):
         flush = self._count_submittable_logs() > 0
         fetch = fetch and not self._slave.get_reserved()
         if not flush and not fetch:
@@ -415,6 +425,14 @@ class Section:
                             self._slave.send_log(self._config.section, logdir, fullname)
                             os.remove(fullname)
 
+                if unreserve:
+                    for logdir in ["new", "reserved"]:
+                        for basename in os.listdir(logdir):
+                            if basename.endswith(".log"):
+                                fullname = os.path.join(logdir, basename)
+                                self._slave.unreserve(fullname)
+                                os.remove(fullname)
+
                 if fetch:
                     max_reserved = int(self._config["max-reserved"])
                     while len(self._slave.get_reserved()) < max_reserved and self._slave.reserve():
@@ -480,7 +498,7 @@ class Section:
             self._slave.forget_reserved(package_name, version)
             if interrupted:
                 break
-        self._talk_to_master()
+        self._talk_to_master(unreserve=interrupted)
         if interrupted:
             raise KeyboardInterrupt
         return test_count

-- 
piuparts git repository



More information about the Piuparts-commits mailing list