[projects/pld-builder.new] builder: go on when queue.html cannot be written

arekm arekm at pld-linux.org
Fri Nov 13 11:26:44 CET 2026


commit a85c7d1420160ffc5069a0c49cfc8db9aca1eced
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Fri Nov 13 09:16:54 2026 +0100

    builder: go on when queue.html cannot be written
    
    A failure while writing queue.txt or queue.html failed the request or
    notification behind it, and bin builders resent notifications, mailing
    the requesters each time. Now it is logged and mailed to the admin once,
    until the pages are written again.

 PLD_Builder/bqueue.py          |  8 ++++++++
 PLD_Builder/mailer.py          | 23 +++++++++++++++++++++++
 PLD_Builder/request_handler.py |  3 +--
 PLD_Builder/srpm_builder.py    |  3 +--
 4 files changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/PLD_Builder/bqueue.py b/PLD_Builder/bqueue.py
index 6b0aa49..2402741 100644
--- a/PLD_Builder/bqueue.py
+++ b/PLD_Builder/bqueue.py
@@ -9,6 +9,8 @@ from io import StringIO
 # PLD_Builder:
 import gpg
 import log
+import mailer
+import path
 import queue_html
 import request
 import util
@@ -42,6 +44,12 @@ class B_Queue:
         queue_html.write(f, self.requests)
         replace_file(fname, f.getvalue())
 
+    def write_pages(self):
+        """Write queue.txt and queue.html, which only show the queue: written and published by then"""
+        with mailer.reported("pages", "writing queue.txt and queue.html"):
+            self.dump(path.queue_stats_file)
+            self.dump_html(path.queue_html_stats_file)
+
     # read possibly compressed, signed queue
     def read_signed(self):
         opener = gzip.open if self.name.endswith(".gz") else open
diff --git a/PLD_Builder/mailer.py b/PLD_Builder/mailer.py
index f60a966..2696d6f 100644
--- a/PLD_Builder/mailer.py
+++ b/PLD_Builder/mailer.py
@@ -1,12 +1,15 @@
 # vi: ts=8 sts=4 sw=4 et
 
+import contextlib
 import os
 import shutil
 import subprocess
 import time
+import traceback
 from io import StringIO
 
 import log
+import path
 import util
 from config import config
 
@@ -86,3 +89,23 @@ class Message:
             p.wait()
             return False
         return p.wait() or None
+
+
+ at contextlib.contextmanager
+def reported(name, what):
+    """Run a block whose failure stops nothing else: logged each time, mailed to the admin once until it works again"""
+    stamp = f"{path.spool_dir}/failing-{name}"
+    try:
+        yield
+    except Exception:  # noqa: BLE001 - any failure; the caller carries on
+        problem = traceback.format_exc()
+        log.alert(f"{what} failed:\n{problem}")
+        if not os.path.exists(stamp):
+            open(stamp, "w").close()
+            m = Message()
+            m.set_headers(to=config.admin_email, subject=f"[{config.builder}] {what} fails")
+            m.write(f"{what} failed, and is not mailed again until it works:\n\n{problem}")
+            m.send()
+    else:
+        if os.path.exists(stamp):
+            os.unlink(stamp)
diff --git a/PLD_Builder/request_handler.py b/PLD_Builder/request_handler.py
index b2302e3..7bf04a5 100644
--- a/PLD_Builder/request_handler.py
+++ b/PLD_Builder/request_handler.py
@@ -162,8 +162,7 @@ def handle_notification(r, user):
     q.write()
     # what the bin builders take their work from; what only shows the queue comes after
     q.write_signed(path.req_queue_signed_file)
-    q.dump(path.queue_stats_file)
-    q.dump_html(path.queue_html_stats_file)
+    q.write_pages()
     q.unlock()
     return HTTPStatus.OK
 
diff --git a/PLD_Builder/srpm_builder.py b/PLD_Builder/srpm_builder.py
index 1b86853..707e73f 100644
--- a/PLD_Builder/srpm_builder.py
+++ b/PLD_Builder/srpm_builder.py
@@ -64,8 +64,7 @@ def store_binary_request(r):
     q.write()
     # what the bin builders take their work from; what only shows the queue comes after
     q.write_signed(path.req_queue_signed_file)
-    q.dump(path.queue_stats_file)
-    q.dump_html(path.queue_html_stats_file)
+    q.write_pages()
     q.unlock()
 
 def transfer_file(r, b):
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list