[projects/pld-builder.new] buildlogs: give each queued buildlog a name of its own

arekm arekm at pld-linux.org
Mon Oct 26 17:16:56 CET 2026


commit 2cfc356886da2ad35e773b9996469c267558864f
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sat Oct 24 13:48:46 2026 +0200

    buildlogs: give each queued buildlog a name of its own
    
    A request built again after a failure wrote its buildlog under the name
    an earlier attempt had already published, and removed it when the
    compression failed: file_sender kept a .desc for a missing file.  Each
    buildlog now gets a spool name of its own.  A later log for the same
    target replaces an earlier one of the same request before it is
    published, so the last one is sent, as before.  A failed .info write
    drops the compressed log like a failed compression does.

 PLD_Builder/buildlogs.py | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/PLD_Builder/buildlogs.py b/PLD_Builder/buildlogs.py
index 90d9170..823bbdd 100644
--- a/PLD_Builder/buildlogs.py
+++ b/PLD_Builder/buildlogs.py
@@ -8,9 +8,16 @@ import os
 import re
 import shutil
 import log
+import util
 
 from config import config
 
+def remove_unpublished(qid):
+    # only for files without a .desc yet; once it exists they belong to file_sender
+    for f in (qid, qid + ".info"):
+        with contextlib.suppress(FileNotFoundError):
+            os.unlink(path.buildlogs_queue_dir + '/' + f)
+
 class Buildlogs_Queue:
     def __init__(self):
         self.queue = []
@@ -25,24 +32,29 @@ class Buildlogs_Queue:
             return
         blogfile = os.path.basename(logfile)
         name = re.sub(r"\.spec\.log", "", blogfile) + "," + id + ".bz2"
-        qfile = path.buildlogs_queue_dir + '/' + config.builder + '.' + id + '.' + blogfile
+        # a name of its own: a retry must not overwrite a buildlog an earlier attempt queued
+        qid = util.uuid()
+        qfile = path.buildlogs_queue_dir + '/' + qid
+        if failed: s = "FAIL"
+        else: s = "OK"
         try:
             with open(logfile, 'rb') as f_in, bz2.open(qfile, 'wb', compresslevel=9) as f_out:
                 shutil.copyfileobj(f_in, f_out)
+            f = open(qfile + ".info", "w")
+            f.write("Status: %s\nEND\n" % s)
+            f.close()
         except OSError as e:
             # queueing it anyway would make file_sender retry a missing file forever
-            log.error(f"compressing buildlog {logfile} failed, not sending it: {e}")
-            with contextlib.suppress(FileNotFoundError):
-                os.unlink(qfile)
+            log.error(f"queueing buildlog {logfile} failed, not sending it: {e}")
+            remove_unpublished(qid)
             return
 
-        if failed: s = "FAIL"
-        else: s = "OK"
-        f = open(path.buildlogs_queue_dir + '/' + config.builder + '.' + id + '.' + blogfile + ".info", "w")
-        f.write("Status: %s\nEND\n" % s)
-        f.close()
+        # a later log for the same target replaces one this request has not published yet
+        for l in [l for l in self.queue if l['name'] == name]:
+            self.queue.remove(l)
+            remove_unpublished(l['id'])
 
-        self.queue.append({'name': name, 'id': config.builder + '.' + id + '.' + blogfile, 'failed': failed})
+        self.queue.append({'name': name, 'id': qid, 'failed': failed})
 
     def flush(self):
         def desc(l):
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/ce9feb3c796ed049b6dd260a50d94d80feb1656d



More information about the pld-cvs-commit mailing list