Problem
I installed a hidden slave in buildbot to avoid overloading. I configured my builds to run in a permanent slave or hidden. The idea is that hidden submission only wakes up when it is needed, but the result is that buildbot randomly selects one subordinate or the other, so I sometimes have to wait until the hidden slave wakes up, even if the constant does not work.
Is there a way to prioritize buildbot slaves?
Attempts to solve
1. Custom nextSlave
Following @ david-dean's suggestion, I created the nextSlave function as follows (upgraded to working version):
from twisted.python import log import traceback def slave_selector(builder, builders): try: host = None support = None for builder in builders: if builder.slave.slavename == 'host-slave': host = builder elif builder.slave.slavename == 'support-slave': support = builder if host and support and len(support.slave.slave_status.runningBuilds) < len(host.slave.slave_status.runningBuilds): log.msg('host-slave has many running builds, launching build in support-slave') return support if not support: log.msg('no support slave found, launching build in host-slave') elif not host: log.msg('no host slave found, launching build in support-slave') return support else: log.msg('launching build in host-slave') return host except Exception as e: log.err(str(e)) log.err(traceback.format_exc()) log.msg('Selecting random slave') return random.choice(buildslaves)
And then passed it to BuilderConfig. As a result, I get this in twistd.log :
2014-04-28 11: 01: 45 + 0200 [-] added buildset 4329 to the database
But the build never starts, in the web interface it always shows up as pending, and none of the logs I put in appear in twistd.log
2. Attempting to mimic default behavior
I have a look at the buildbot code to see how this is done by default. in the file ./master/buildbot/process/buildrequestdistributor.py , class BasicBuildChooser you have:
self.nextSlave = self.bldr.config.nextSlave if not self.nextSlave: self.nextSlave = lambda _,slaves: random.choice(slaves) if slaves else None
So, I installed exactly this lambda function in my BuilderConfig , and I get exactly the same build result, and not start.
buildbot
hithwen
source share