[projects/pld-builder.new] queue: note when each builder started and ended a build
arekm
arekm at pld-linux.org
Thu Nov 12 09:18:39 CET 2026
commit b4691f1e0c7c33726b8f1e2f1bf004e106168610
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Nov 12 09:17:38 2026 +0100
queue: note when each builder started and ended a build
A notification now carries the time the builder had the status, by its
own clock, and the queue keeps when a build began and ended. Statuses
and times in a request sent in are ignored. Replaces buildtime, which
was always 0.
PLD_Builder/notify.py | 3 ++-
PLD_Builder/queue_html.py | 6 ++---
PLD_Builder/request.py | 53 +++++++++++++++++++++++++++++++-----------
PLD_Builder/request_handler.py | 3 +--
4 files changed, 45 insertions(+), 20 deletions(-)
---
diff --git a/PLD_Builder/notify.py b/PLD_Builder/notify.py
index b8327f0..910519e 100644
--- a/PLD_Builder/notify.py
+++ b/PLD_Builder/notify.py
@@ -1,5 +1,6 @@
# vi: ts=8 sts=4 sw=4 et
+import time
from io import StringIO
import gpg
@@ -29,7 +30,7 @@ def add_batch(batch, status, after=()):
With after, ids of files in the ftp queue, it is sent only once they are.
"""
- xml = (f"<notification group-id='{group.id}' builder='{config.builder}'>\n"
+ xml = (f"<notification group-id='{group.id}' builder='{config.builder}' time='{time.time()}'>\n"
f" <batch id='{batch.b_id}' status='{status}' />\n"
"</notification>\n")
try:
diff --git a/PLD_Builder/queue_html.py b/PLD_Builder/queue_html.py
index abca824..be39f5a 100644
--- a/PLD_Builder/queue_html.py
+++ b/PLD_Builder/queue_html.py
@@ -113,15 +113,15 @@ def write_batch(f, b, rid):
f"&ok={is_ok}&name={quote(bl_name)}&id={quote(rid)}&action=tail\">"
link_post = "</a>"
- def ftime(s):
- t = float(s)
+ def ftime(t):
if t > 0:
return time.asctime(time.localtime(t))
else:
return 'N/A'
tooltip = (f"last update: {ftime(b.builders_status_time[builder])}\n"
- f"build time: {ftime(b.builders_status_buildtime[builder])}")
+ f"build started: {ftime(b.builders_build_start.get(builder, 0))}\n"
+ f"build ended: {ftime(b.builders_build_end.get(builder, 0))}")
builders.append(link_pre +
f"<font color='{c}'><b title=\"{html.escape(tooltip, True)}\">"
f"{escape(builder)}:{escape(s)}</b></font>"
diff --git a/PLD_Builder/request.py b/PLD_Builder/request.py
index 915a9d6..cc1f922 100644
--- a/PLD_Builder/request.py
+++ b/PLD_Builder/request.py
@@ -140,8 +140,11 @@ class Batch:
self.bconds_without = []
self.builders = []
self.builders_status = {}
+ # when each builder got its present status, and when it started and ended the build:
+ # 0 for a build not that far, or one the src builder was not told about
self.builders_status_time = {}
- self.builders_status_buildtime = {}
+ self.builders_build_start = {}
+ self.builders_build_end = {}
self.kernel = ""
self.defines = {}
self.target = []
@@ -201,8 +204,9 @@ class Batch:
key = text(c)
self.builders.append(key)
self.builders_status[key] = attr(c, "status", "?")
- self.builders_status_time[key] = attr(c, "time", "0")
- self.builders_status_buildtime[key] = "0" #attr(c, "buildtime", "0")
+ self.builders_status_time[key] = float(attr(c, "time", "0"))
+ self.builders_build_start[key] = float(attr(c, "started", "0"))
+ self.builders_build_end[key] = float(attr(c, "built", "0"))
elif c.nodeName == "with":
self.bconds_with.append(text(c))
elif c.nodeName == "without":
@@ -233,6 +237,26 @@ class Batch:
ok = 0
return ok
+ def start_waiting(self):
+ """Every builder waits for a request just taken in, whatever the request says of them"""
+ self.builders_status = dict.fromkeys(self.builders, "?")
+ self.builders_status_time = dict.fromkeys(self.builders, time.time())
+ self.builders_build_start = {}
+ self.builders_build_end = {}
+
+ def set_status(self, builder, status, when):
+ """Take the status a builder reports it had at when, which tells when its build starts and ends"""
+ was = self.builders_status.get(builder)
+ # a notification is sent again when it did not get through
+ if status == was:
+ return
+ if status == "BUILDING":
+ self.builders_build_start[builder] = when
+ elif was == "BUILDING":
+ self.builders_build_end[builder] = when
+ self.builders_status[builder] = status
+ self.builders_status_time[builder] = when
+
def dump(self, f):
f.write(f" batch: {self.src_rpm}/{self.spec}\n")
f.write(f" info: {self.info}\n")
@@ -381,12 +405,9 @@ class Batch:
if self.defines:
f.write(f" {self.defines_xml()}\n")
for b in self.builders:
- if b in self.builders_status_buildtime:
- t = self.builders_status_buildtime[b]
- else:
- t = "0"
f.write(f" <builder status='{escape(self.builders_status[b])}' "
- f"time='{self.builders_status_time[b]}' buildtime='{t}'>{escape(b)}</builder>\n")
+ f"time='{self.builders_status_time[b]}' started='{self.builders_build_start.get(b, 0)}' "
+ f"built='{self.builders_build_end.get(b, 0)}'>{escape(b)}</builder>\n")
f.write(" </batch>\n")
def log_line(self, l):
@@ -413,8 +434,16 @@ class Notification:
self.kind = 'notification'
self.group_id = attr(e, "group-id")
self.builder = attr(e, "builder")
+ # when the builder had the status, by its clock: a notification may wait long to be sent.
+ # An older builder does not say, and a time that cannot be is not taken
+ now = time.time()
+ try:
+ self.time = float(attr(e, "time", now))
+ except ValueError:
+ self.time = now
+ if not 0 < self.time <= now:
+ self.time = now
self.batches = {}
- self.batches_buildtime = {}
for c in e.childNodes:
if is_blank(c): continue
if c.nodeType != Element.ELEMENT_NODE:
@@ -422,11 +451,9 @@ class Notification:
if c.nodeName == "batch":
id = attr(c, "id")
status = attr(c, "status")
- buildtime = attr(c, "buildtime", "0")
if not is_final(status) and status not in PROGRESS_STATUSES[1:]:
log.panic(f"xml notification: bad status: {status}")
self.batches[id] = status
- self.batches_buildtime[id] = buildtime
else:
log.panic(f"xml: evil notification child ({c.nodeName})")
@@ -437,9 +464,7 @@ class Notification:
# notifications are resent on failure, so an older one can come late
if b.b_id in self.batches and \
status_rank(self.batches[b.b_id]) >= status_rank(b.builders_status.get(self.builder, "?")):
- b.builders_status[self.builder] = self.batches[b.b_id]
- b.builders_status_time[self.builder] = time.time()
- b.builders_status_buildtime[self.builder] = "0" #self.batches_buildtime[b.b_id]
+ b.set_status(self.builder, self.batches[b.b_id], self.time)
def build_request(e):
if e.nodeType != Element.ELEMENT_NODE:
diff --git a/PLD_Builder/request_handler.py b/PLD_Builder/request_handler.py
index 8d720c7..f2c0dbf 100644
--- a/PLD_Builder/request_handler.py
+++ b/PLD_Builder/request_handler.py
@@ -88,9 +88,8 @@ def handle_group(r, user):
if not batch.is_command() and config.builder in batch.builders:
batch.builders.remove(config.builder)
+ batch.start_waiting()
for bld in batch.builders:
- batch.builders_status[bld] = '?'
- batch.builders_status_time[bld] = time.time()
if bld not in config.binary_builders and bld != config.builder:
binary_builders = ' '.join(config.binary_builders)
return refuse(HTTPStatus.BAD_REQUEST,
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/9c47734c3e1a74461984048eaf31b4d1efc7d2a3
More information about the pld-cvs-commit
mailing list