mirror of
git://git.yoctoproject.org/yocto-autobuilder2.git
synced 2025-07-19 20:59:02 +02:00
builders/scheduler: Add ability to select the worker to run on
Thanks to tardyp for the pointer to an example of how to make this work! Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
62e4e2b174
commit
b0f684ee64
11
builders.py
11
builders.py
|
@ -7,6 +7,7 @@ from datetime import datetime
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
builders = []
|
builders = []
|
||||||
|
@ -189,6 +190,14 @@ def create_builder_factory():
|
||||||
timeout=16200)) # default of 1200s/20min is too short, use 4.5hrs
|
timeout=16200)) # default of 1200s/20min is too short, use 4.5hrs
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
def nextWorker(bldr, workers, buildrequest):
|
||||||
|
forced_worker = buildrequest.properties.getProperty("worker", "*")
|
||||||
|
if forced_worker == "*":
|
||||||
|
return random.choice(workers) if workers else None
|
||||||
|
for w in workers:
|
||||||
|
if w.worker.workername == forced_worker:
|
||||||
|
return w
|
||||||
|
return None # worker not yet available
|
||||||
|
|
||||||
# regular builders
|
# regular builders
|
||||||
f = create_builder_factory()
|
f = create_builder_factory()
|
||||||
|
@ -197,7 +206,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,
|
workernames=workers, nextWorker=nextWorker,
|
||||||
factory=f, env=extra_env))
|
factory=f, env=extra_env))
|
||||||
|
|
||||||
def create_parent_builder_factory(buildername, waitname):
|
def create_parent_builder_factory(buildername, waitname):
|
||||||
|
|
|
@ -74,8 +74,14 @@ def props_for_builder(builder):
|
||||||
label="Do we want to deploy artefacts? ",
|
label="Do we want to deploy artefacts? ",
|
||||||
default=False
|
default=False
|
||||||
))
|
))
|
||||||
|
|
||||||
props = props + repos_for_builder(builder)
|
props = props + repos_for_builder(builder)
|
||||||
|
worker_list = config.builder_to_workers.get(builder, config.builder_to_workers['default'])
|
||||||
|
props.append(util.ChoiceStringParameter(name="worker",
|
||||||
|
label="Worker to run the build on",
|
||||||
|
default="*",
|
||||||
|
multiple=False,
|
||||||
|
strict=True,
|
||||||
|
choices=worker_list))
|
||||||
return props
|
return props
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user