[projects/pld-builder.new] builder: skip a request by a flag in the queue, not a skipme file

arekm arekm at pld-linux.org
Sun Nov 15 01:57:41 CET 2026


commit 38cb9faefe58172300fc48a0dc7ce5c8babef6ea
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sat Nov 14 22:44:47 2026 +0100

    builder: skip a request by a flag in the queue, not a skipme file
    
    The src builder flags the request in the queue the bin builders take, the
    request fetcher brings the flag into their queues, and they check it there
    before each package instead of asking the src builder over http.
    queue.html shows the flag.
    
    Src and bin builders go together: each ignores the other's old way.

 PLD_Builder/build.py           | 37 +++++++++++++++++++++++++------------
 PLD_Builder/queue_html.py      |  4 ++--
 PLD_Builder/request_fetcher.py | 10 ++++++++--
 PLD_Builder/rpm_builder.py     | 35 ++++++++---------------------------
 PLD_Builder/style.css          |  6 ++++++
 client/make-request.sh         |  2 +-
 6 files changed, 50 insertions(+), 44 deletions(-)
---
diff --git a/PLD_Builder/build.py b/PLD_Builder/build.py
index d50cc5d..386b293 100644
--- a/PLD_Builder/build.py
+++ b/PLD_Builder/build.py
@@ -14,6 +14,7 @@ import report
 import status
 import stopwatch
 import util
+from bqueue import B_Queue
 from config import config
 
 
@@ -21,20 +22,32 @@ def log_command(batch, where):
     # indented below, so no line of the command reads as its output
     util.append_to(batch.logfile, f"running {where}:\n" + "\n".join(f"    {l}" for l in batch.command.splitlines()))
 
+def skip_requests(batch, ids):
+    """Flag the requests for the bin builders to skip; they get the flag with the queue this command goes out in"""
+    if config.builder != config.src_builder:
+        util.append_to(batch.logfile, "skip: only the src builder skips requests")
+        return 1
+    q = B_Queue(path.req_queue_file)
+    q.lock(0)
+    try:
+        q.read()
+        queued = {r.id: r for r in q.requests}
+        for id in ids:
+            if id in queued and "skip" not in queued[id].flags:
+                queued[id].flags.append("skip")
+        q.write()
+    finally:
+        q.unlock()
+    # make-request checks the ids against the queue: one gone since has nothing left to skip.  Not a failure,
+    # as a failed command is not sent on and its flags would reach no bin builder
+    for id in ids:
+        util.append_to(batch.logfile, f"skip:{id}" if id in queued else f"{id} is not in the queue any more")
+    return 0
+
 def run_command(batch):
-    # we want to keep "skip" in queue.html
     command = batch.command
-
-    # rewrite special "skip:BUILD_ID into touch
-    if command[:5] == "skip:":
-        c = ""
-        for id in command[5:].split(','):
-            if os.path.isdir(path.srpms_dir + '/' + id):
-                c = c + f"echo skip:{id};\n"
-                c = c + f"touch {path.srpms_dir}/{id}/skipme;\n"
-            else:
-                c = c + f"echo {id} is not valid build-id;\n"
-        command = c
+    if command.startswith("skip:"):
+        return skip_requests(batch, command[5:].split(","))
 
     if "no-chroot" in batch.command_flags:
         log_command(batch, "outside chroot")
diff --git a/PLD_Builder/queue_html.py b/PLD_Builder/queue_html.py
index 1636b0b..8ea01ca 100644
--- a/PLD_Builder/queue_html.py
+++ b/PLD_Builder/queue_html.py
@@ -270,7 +270,7 @@ def build_log(batch, builder, status, request_id):
 LEGEND = """<h2>How to read a request</h2>
 <section class="request legend">
 <header><span class=no>number</span> <b class=from>who sent it</b> <span class="flag upgrade">upgrade</span>
- or <span class="flag test-build">test-build</span> <span class=rid>priority, request id with its src.rpm files</span>
+ or <span class="flag test-build">test-build</span>, <span class="flag skip">skip</span> when asked to stop <span class=rid>priority, request id with its src.rpm files</span>
  <span class=sent>queued: when the src builder took the request in</span></header>
 <div class=batch>
 <div class=what><b>package-version-release</b> spec and branch with their git log, build options</div>
@@ -282,7 +282,7 @@ LEGEND = """<h2>How to read a request</h2>
 <span class=span>start → end</span>
 <p>Failed, here in %build of the spec.</p></div>
 <div class=builder><span class=who>builder</span><span class=state><b class="s skip">SKIP</b></span><span class=span>time</span>
-<p>Not built: a package earlier in this request failed. UNSUPP: the spec excludes this architecture.</p></div>
+<p>Not built: a package earlier in this request failed. SKIP_REQUESTED: the request was skipped. UNSUPP: the spec excludes this architecture.</p></div>
 </div>
 </div>
 <div class=batch>
diff --git a/PLD_Builder/request_fetcher.py b/PLD_Builder/request_fetcher.py
index b88793d..df11051 100644
--- a/PLD_Builder/request_fetcher.py
+++ b/PLD_Builder/request_fetcher.py
@@ -87,13 +87,18 @@ def fetch_queue(control_url):
         sys.exit(1)
     return request.parse_requests(body)
 
-def handle_reqs(builder, reqs):
+def handle_reqs(builder, reqs, skipped):
+    """Queue the new requests reqs for builder, and flag those it has that the src builder asks to skip"""
     qpath = path.queue_file + "-" + builder
     if not os.access(qpath, os.F_OK):
         util.append_to(qpath, "<queue/>\n")
     q = B_Queue(qpath)
     q.lock(0)
     q.read()
+    for r in q.requests:
+        if r.id in skipped and "skip" not in r.flags:
+            log.notice(f"skipping {r.id} ({r.no}) on {builder}")
+            r.flags.append("skip")
     for r in reqs:
         if r.kind != 'group':
             raise RuntimeError(f'handle_reqs: fatal: huh? {r.kind}')
@@ -123,8 +128,9 @@ def main():
             max_no = max(max_no, r.no)
             if r.no > last_count:
                 q_new.append(r)
+        skipped = {r.id for r in q if "skip" in r.flags}
         for b in config.binary_builders:
-            handle_reqs(b, q_new)
+            handle_reqs(b, q_new, skipped)
         with open(path.last_req_no_file, "w") as f:
             f.write(f"{max_no}\n")
     status.pop()
diff --git a/PLD_Builder/rpm_builder.py b/PLD_Builder/rpm_builder.py
index cf680b2..760d94d 100644
--- a/PLD_Builder/rpm_builder.py
+++ b/PLD_Builder/rpm_builder.py
@@ -57,32 +57,13 @@ def pick_request(q):
     ret = q.requests[0]
     return ret
 
-def check_skip_build(r, b):
-    src_url = config.control_url + "/srpms/" + r.id + "/skipme"
-    good  = False
-    b.log_line("checking if we should skip the build")
-    while not good:
-        try:
-            headers = { 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' }
-            req = urllib.request.Request(url=src_url, headers=headers)
-            f = urllib.request.urlopen(req)
-            good = True
-        except urllib.error.HTTPError:
-            return False
-        except urllib.error.URLError as error:
-            # URLError.errno is always None; the real errno is on the wrapped
-            # exception in error.reason
-            errno = getattr(error.reason, 'errno', None)
-            # see errno.h
-            if errno in [-3, 60, 61, 110, 111]:
-                b.log_line("unable to connect... trying again")
-                time.sleep(retry_delay)
-                continue
-            else:
-                return False
-        f.close()
-        return True
-    return False
+def skip_requested(r):
+    """Whether the src builder asks to skip r: the request fetcher flags it in this builder's queue"""
+    q = B_Queue(path.queue_file + "-" + config.builder)
+    q.lock(0)
+    q.read()
+    q.unlock()
+    return any(x.id == r.id and "skip" in x.flags for x in q.requests)
 
 def fetch_src(r, b):
     """Copy the src.rpm into the chroot.  False when it is gone for good."""
@@ -188,7 +169,7 @@ def build_rpm(r, b):
     status.push(f"building {b.spec} ({packagename})")
     b.log_line(f"request from: {r.requester}")
 
-    if check_skip_build(r, b):
+    if skip_requested(r):
         b.log_line("build skipped due to src builder request")
         res = "SKIP_REQUESTED"
         status.pop()
diff --git a/PLD_Builder/style.css b/PLD_Builder/style.css
index 6fb1dae..a094375 100644
--- a/PLD_Builder/style.css
+++ b/PLD_Builder/style.css
@@ -152,6 +152,12 @@ h2 {
 	color: #fff;
 }
 
+.flag.skip {
+	background: #c62828;
+	border-color: #c62828;
+	color: #fff;
+}
+
 .sent {
 	margin-left: 12px;
 }
diff --git a/client/make-request.sh b/client/make-request.sh
index 2a1f02b..32a7110 100755
--- a/client/make-request.sh
+++ b/client/make-request.sh
@@ -281,7 +281,7 @@ Mandatory arguments to long options are mandatory for short options too.
       -D "NAME VALUE"|--define "NAME VALUE"
             define macro named NAME with value VALUE
       -s BUILD_ID, --skip BUILD_ID[,BUILD_ID][,BUILD_ID]
-            mark build ids on src builder to be skipped (instructs srcbuilder to create 'skipme' file)
+            skip the requests with these build ids: bin builders do not start them and stop their running rpmbuild
       --branch VALUE
             specify default branch for specs in request
       -t, --test-build
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list