Buildbot奴隶优先 [英] Buildbot slaves priority

查看:83
本文介绍了Buildbot奴隶优先的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在buildbot中设置了一个潜在奴隶,以帮助避免拥塞。
我已经设置好了要在永久奴隶或潜在奴隶中运行的构建。这个想法是潜在的从属设备仅在需要时才被唤醒,但结果是buildbot随机选择一个或另一个从属设备,因此有时即使永久的一个空闲,我也必须等待潜在的从属设备唤醒。

I have set up a latent slave in buildbot to help avoid congestion. I've set up my builds to run either in permanent slave or latent one. The idea is the latent slave is waken up only when needed but the result is that buildbot randomly selectes one slave or the other so sometimes I have to wait for the latent slave to wake even if the permanent one is idle.

有没有一种方法可以优先选择buildbot从属?

Is there a way to prioritize buildbot slaves?

按照@ david-dean的建议,我创建了nextSlave函数,如下所示(更新为工作版本):

Following @david-dean suggestion, I've created a nextSlave function as follows (updated 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)

然后将其传递给BuilderConfig。
结果是我在 twistd.log 中得到了此信息:

And then passed it to BuilderConfig. The result is that I get this in twistd.log:


2014-04-28 11:01:45 + 0200 [-]向数据库中添加了构建集4329

2014-04-28 11:01:45+0200 [-] added buildset 4329 to database

但是构建从未开始,在网络用户界面中,它始终显示为待处理,我放置的所有日志都没有出现在 twistd.log

But the build never starts, in the web UI it always appear as Pending and none of the logs I've put appear in twistd.log

我正在构建机器人代码,以了解默认情况下的行为。文件中的
。/ master / buildbot / process / buildrequestdistributor.py
,类 BasicBuildChooser 您具有:

I've having a look to buildbot code, to see how it is done by default. in 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

所以我已经在我的 BuilderConfig 中完全设置该lambda函数,得到的构建完全相同,而不是初始结果。

So I've set exactly that lambda function in my BuilderConfig and I'm getting exactly the same build not starting result.

推荐答案

您可以设置nextSlave函数以自定义方式将从属分配给构建器,请参见: http://docs.buildbot.net/current/manual/cfg-builders.html#builder-configuration

You can set up a nextSlave function to assign slaves to a builder in a custom manner see: http://docs.buildbot.net/current/manual/cfg-builders.html#builder-configuration

这篇关于Buildbot奴隶优先的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆