builders: Add prioritizeBuilders

This prioritizeBuilders function sorts builders by the length of their
associated worker lists, so that builders that can only be assigned to a
small number of workers are assigned to those workers before other
builds that don't have specific needs when resources are limited. An
example might be when a slot is available on an Ubuntu-based worker, and
"oe-selftest-ubuntu" and "genericx86-64" build requests exist in the
queue. Since oe-selftest-ubuntu requires an Ubuntu-based worker and
genericx86-64 does not, genericx86-64 will be assigned a higher value
(lower priority) so that oe-selftest-ubuntu is assigned to that worker
first.

[YOCTO #13644]

Signed-off-by: Trevor Gamblin <trevor.gamblin@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Trevor Gamblin 2021-09-09 09:10:12 -04:00 committed by Richard Purdie
parent e0c1452d5a
commit b5a047f99f
2 changed files with 19 additions and 0 deletions

View File

@ -135,6 +135,19 @@ for builder in config.subbuilders:
workernames=workers, nextWorker=nextWorker, nextBuild=nextBuild, workernames=workers, nextWorker=nextWorker, nextBuild=nextBuild,
factory=f, env=extra_env)) factory=f, env=extra_env))
# prioritize assigning builders to available workers based on the length
# of the worker lists they are associated with. Builders that have fewer
# valid worker options should always be assigned first
def prioritizeBuilders(buildmaster, builders):
# re-use the builder_to_workers list
builder_to_workers = config.builder_to_workers
# sort builders by the length of their worker lists. Since not all
# builders are explicitly listed in builder_to_workers, make sure to
# default to the len() of the "default" value
builders.sort(key=lambda b: len(builder_to_workers.get(b.name)) if b.name in builder_to_workers.keys() else len(builder_to_workers.get("default")))
return builders
def create_parent_builder_factory(buildername, waitname): def create_parent_builder_factory(buildername, waitname):
factory = util.BuildFactory() factory = util.BuildFactory()
# NOTE: Assumes that yocto-autobuilder repo has been cloned to home # NOTE: Assumes that yocto-autobuilder repo has been cloned to home

View File

@ -88,6 +88,12 @@ c['www'] = www.www
# These items are specific to an individual AB deployment # These items are specific to an individual AB deployment
c['workers'] = workers.workers c['workers'] = workers.workers
# This enables our prioritizeBuilders function from builders.py.
# Builders such as buildperf-centos7, buildperf-ubuntu1604,
# oe-selftest-*, and reproducible-* will be assigned (if possible)
# before other builders since their possible worker lists are smaller
c['prioritizeBuilders'] = builders.prioritizeBuilders
c['title'] = "Yocto Autobuilder" c['title'] = "Yocto Autobuilder"
c['titleURL'] = "https://autobuilder.yoctoproject.org/main/" c['titleURL'] = "https://autobuilder.yoctoproject.org/main/"
# visible location for internal web server # visible location for internal web server