builders: Add randomised nextBuild function

nextWorker  can block a request if there is no worker available.
_getNextUnclaimedBuildRequest will always return the first request
which then will always fail to find worker, and this will block the queue
We therefore randomise the build requests queue with nextBuild to avoid
blocking.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2019-11-07 11:37:03 +00:00
parent 5f370fbce0
commit 3b290ec6d7

View File

@ -215,6 +215,14 @@ def nextWorker(bldr, workers, buildrequest):
return w return w
return None # worker not yet available return None # worker not yet available
# nextWorker above can block a request if there is no worker available.
# _getNextUnclaimedBuildRequest will always return the first request
# which then will always fail to find worker, and this will block the queue
# We therefore randomise the build requests queue with nextBuild to avoid
# blocking
def nextBuild(bldr, requests):
return random.choice(requests) if requests else None
# regular builders # regular builders
f = create_builder_factory() f = create_builder_factory()
for builder in config.subbuilders: for builder in config.subbuilders:
@ -222,7 +230,7 @@ for builder in config.subbuilders:
if not workers: if not workers:
workers = config.builder_to_workers['default'] workers = config.builder_to_workers['default']
builders.append(util.BuilderConfig(name=builder, builders.append(util.BuilderConfig(name=builder,
workernames=workers, nextWorker=nextWorker, workernames=workers, nextWorker=nextWorker, nextBuild=nextBuild,
factory=f, env=extra_env)) factory=f, env=extra_env))
def create_parent_builder_factory(buildername, waitname): def create_parent_builder_factory(buildername, waitname):
@ -350,5 +358,5 @@ def create_parent_builder_factory(buildername, waitname):
return factory return factory
builders.append(util.BuilderConfig(name="a-quick", workernames=config.workers, factory=create_parent_builder_factory("a-quick", "wait-quick"), nextWorker=nextWorker, env=extra_env)) builders.append(util.BuilderConfig(name="a-quick", workernames=config.workers, factory=create_parent_builder_factory("a-quick", "wait-quick"), nextWorker=nextWorker, nextBuild=nextBuild, env=extra_env))
builders.append(util.BuilderConfig(name="a-full", workernames=config.workers, factory=create_parent_builder_factory("a-full", "wait-full"), nextWorker=nextWorker, env=extra_env)) builders.append(util.BuilderConfig(name="a-full", workernames=config.workers, factory=create_parent_builder_factory("a-full", "wait-full"), nextWorker=nextWorker, nextBuild=nextBuild, env=extra_env))