我在buildbot中设置了一个潜在的奴隶来帮助避免拥塞。 我已将我的构建设置为在永久奴隶或潜在奴隶中运行。想法是潜在的奴隶只在需要时被唤醒,但结果是buildbot随机选择一个奴隶或另一个奴隶,所以有时我必须等待潜在的奴隶醒来,即使永久奴隶是空闲的。
有没有办法优先构建buildbot奴隶?
按照@ david-dean的建议,我已经创建了一个nextSlave函数,如下所示(更新为工作版本):
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)
然后将其传递给BuilderConfig。
结果是我在twistd.log
中得到了这个:
2014-04-28 11:01:45 + 0200 [ - ]将buildset 4329添加到数据库
但是构建永远不会开始,在网络用户界面中它始终显示为待定,而且我在twistd.log
我已经看过buildbot代码,看看它是如何在默认情况下完成的。
在文件./master/buildbot/process/buildrequestdistributor.py
,类BasicBuildChooser
中,您有:
self.nextSlave = self.bldr.config.nextSlave
if not self.nextSlave:
self.nextSlave = lambda _,slaves: random.choice(slaves) if slaves else None
所以我在我的BuilderConfig
中准确设置了lambda函数,并且我得到了完全相同的构建而没有开始结果。
答案 0 :(得分:2)
您可以设置nextSlave函数,以自定义方式将构建器分配给构建器,请参阅:http://docs.buildbot.net/current/manual/cfg-builders.html#builder-configuration