Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phase1: raise priority of tag builds #18

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request:

env:
BUILDBOT_VERSION: 3.8.0
BUILDBOT_VERSION: 3.9.0
GITHUB_SHA_LEN: 8

concurrency:
Expand Down
31 changes: 19 additions & 12 deletions phase1/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,20 @@ c["configurators"] = [


@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"),
Expand All @@ -212,7 +216,7 @@ def getNewestCompleteTime(bldr):
limit=1,
)
if not completed:
return
return (prio, None)

complete_at = completed[0]["complete_at"]

Expand All @@ -228,9 +232,9 @@ def getNewestCompleteTime(bldr):
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
Expand All @@ -245,25 +249,28 @@ def prioritizeBuilders(master, builders):
i = 1
for bname in branchNames:
bldrNamePrio[bname] = i
i += 1

def is_building(bldr):
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 if any [1..50], !tag builds [51...]

if not complete_at:
date = datetime.min
complete_at = date.replace(tzinfo=tzutc())
Expand Down Expand Up @@ -531,7 +538,7 @@ c["schedulers"].append(
)

c["schedulers"].append(
schedulers.Triggerable(name="trigger", builderNames=builderNames)
schedulers.Triggerable(name="trigger", builderNames=builderNames, priority=20)
)

####### BUILDERS
Expand Down