From d86ad1742e6e1f705d9a0491162db1c82c0e4d9f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thibaut=20VAR=C3=88NE?= Date: Thu, 27 Oct 2022 13:27:56 +0200 Subject: [PATCH] phase1: prioritize builders by branch order MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Thibaut VARÈNE --- phase1/master.cfg | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/phase1/master.cfg b/phase1/master.cfg index ee250e3..0bb23b2 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -205,11 +205,17 @@ def getNewestCompleteTime(bldr): @defer.inlineCallbacks def prioritizeBuilders(master, builders): """Returns sorted list of builders by their last timestamp of completed and - not skipped build. + not skipped build, ordered first by branch name. @returns: list of sorted builders """ + bldrNamePrio = { "__Janitor": 0, "00_force_build": 0 } + i = 1 + for bname in branchNames: + bldrNamePrio[bname] = i + i += 1 + def is_building(bldr): return bool(bldr.building) or bool(bldr.old_building) @@ -221,10 +227,11 @@ def prioritizeBuilders(master, builders): def bldr_sort(item): (complete_at, bldr) = item - if bldr.name == "00_force_build": - date = datetime.min - complete_at = date.replace(tzinfo=tzutc()) - return (complete_at, bldr.name) + pos = 99 + for (name, prio) in bldrNamePrio.items(): + if bldr.name.startswith(name): + pos = prio + break if not complete_at: date = datetime.min @@ -234,7 +241,7 @@ def prioritizeBuilders(master, builders): date = datetime.max complete_at = date.replace(tzinfo=tzutc()) - return (complete_at, bldr.name) + return (pos, complete_at, bldr.name) results = yield defer.gatherResults([bldr_info(bldr) for bldr in builders]) results.sort(key=bldr_sort) @@ -513,11 +520,6 @@ def GetNextBuild(builder, requests): # order tagged build first if r.properties.hasProperty("tag"): return r - # then order by branch order - pbranch = r.properties.getProperty("branch") - for name in branchNames: - if pbranch == name: - return r r = requests[0] log.msg("GetNextBuild: {:>20} id: {} bsid: {}".format(builder.name, r.id, r.bsid)) -- 2.30.2