mirror of
git://git.yoctoproject.org/yocto-autobuilder2.git
synced 2025-07-04 20:54:48 +02:00
builders: Rework least loaded worker finding in nextWorker()
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
This commit is contained in:
parent
776469c3ae
commit
ea0077dce7
23
builders.py
23
builders.py
|
@ -178,25 +178,16 @@ def nextWorker(bldr, workers, buildrequest):
|
||||||
[resultspec.Filter('complete', 'eq', [False])],
|
[resultspec.Filter('complete', 'eq', [False])],
|
||||||
)
|
)
|
||||||
|
|
||||||
active = {}
|
active = {worker.worker.workerid: 0 for worker in possible_workers}
|
||||||
maxbuilds = 0
|
|
||||||
for build in builds:
|
for build in builds:
|
||||||
if build['workerid'] not in active:
|
if build['workerid'] in active:
|
||||||
active[build['workerid']] = 1
|
|
||||||
else:
|
|
||||||
active[build['workerid']] += 1
|
active[build['workerid']] += 1
|
||||||
if maxbuilds > active[build['workerid']]:
|
least_actives = [k for k, v in active.items() if v == min(active.values())]
|
||||||
maxbuilds = active[build['workerid']]
|
|
||||||
|
|
||||||
random.shuffle(possible_workers)
|
possible_workers = [worker for worker in possible_workers
|
||||||
|
if worker.worker.workerid in least_actives]
|
||||||
for worker in possible_workers:
|
if possible_workers:
|
||||||
if worker.worker.workerid not in active:
|
return random.choice(possible_workers)
|
||||||
return worker
|
|
||||||
for i in range(maxbuilds):
|
|
||||||
for worker in possible_workers:
|
|
||||||
if active[worker.worker.workerid] == i:
|
|
||||||
return worker
|
|
||||||
|
|
||||||
return None
|
return None
|
||||||
for w in possible_workers:
|
for w in possible_workers:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user