@defer.inlineCallbacks
-def getNewestCompleteTime(bldr):
- """Returns the complete_at of the latest completed and not SKIPPED
+def getNewestCompleteTimePrio(bldr):
+ """Returns the priority and the complete_at of the latest completed and not SKIPPED
build request for this builder, or None if there are no such build
requests. We need to filter out SKIPPED requests because we're
using collapseRequests=True which is unfortunately marking all
previous requests as complete when new buildset is created.
- @returns: datetime instance or None, via Deferred
+ @returns: (priority, datetime instance or None), via Deferred
"""
+ prio = yield bldr.get_highest_priority()
+ if prio is None:
+ prio = 0
+
bldrid = yield bldr.getBuilderId()
completed = yield bldr.master.data.get(
("builders", bldrid, "buildrequests"),
limit=1,
)
if not completed:
- return
+ return (prio, None)
complete_at = completed[0]["complete_at"]
if last_build and last_build[0]:
last_complete_at = last_build[0]["complete_at"]
if last_complete_at and (last_complete_at > complete_at):
- return last_complete_at
+ return (prio, last_complete_at)
- return complete_at
+ return (prio, complete_at)
@defer.inlineCallbacks
return bool(bldr.building) or bool(bldr.old_building)
def bldr_info(bldr):
- d = defer.maybeDeferred(getNewestCompleteTime, bldr)
- d.addCallback(lambda complete_at: (complete_at, bldr))
+ d = defer.maybeDeferred(getNewestCompleteTimePrio, bldr)
+ d.addCallback(lambda retval: (retval, bldr))
return d
def bldr_sort(item):
- (complete_at, bldr) = item
+ ((hiprio, complete_at), bldr) = item
+ # check if we have some high prio build requests pending (i.e. tag builds),
+ # if so, front-run these builders, while preserving the per-branch static priority
pos = 99
for name, prio in bldrNamePrio.items():
if bldr.name.startswith(name):
- pos = prio
+ pos = prio + 50 - min(hiprio, 50) # higher priority (larger positive number) raises position
break
+ # pos order: janitor/local (0), tag builds per branch order if any [1..50], !tag builds per branch order [51...]
+
if not complete_at:
date = datetime.min
complete_at = date.replace(tzinfo=tzutc())
)
c["schedulers"].append(
- schedulers.Triggerable(name="trigger", builderNames=builderNames)
+ schedulers.Triggerable(name="trigger", builderNames=builderNames, priority=20)
)
####### BUILDERS