[Buildbot-devel] Dynamic master lock per change request

Pierre Tardy tardyp at gmail.com
Fri Oct 17 12:18:06 UTC 2014

Hi Vitali,

I think that your approach is workable. The Build object is created by
buildfactory. You may override it by changing the BuildFactory.buildClass

Your use case is valid enough to deserve improvement in the lock API, to
provide people something more idiomatic, and simple to reproduce for other

For now, the RealLock api use the following api: lock.getLock(slave), which
allows to implement SlaveLock, and MasterLock.

I think we could change the API so that lock.getLock takes a Properties
object, and then create a PropertyLock(propertyname) implementation.

Then SlaveLock would become equivalent to PropertyLock("slavename"), and
MasterLock would become PropertyLock(None)

We could even enhance the idea to create a RenderableLock() which would
take a IRenderable object.

I think that is a great simple project for a first contribution. :)

Let us know if you are interested, and don't hesitate to request help here
or in #buildbot.



On Fri, Oct 17, 2014 at 5:50 AM, Vitali Lovich <vlovich at gmail.com> wrote:

> Hi,
> I’m wondering if anyone has any ideas on how to dynamically adjust the set
> of locks
> needed for a build on a per change-request basis.
> The context is that the master lock that gets acquired depends on the
> codebase that a
> builder is building (I can have n independent projects using the builder,
> but the builder
> can only process 1 build per project at a time).
> I’m currently looking at over-riding the Build.startBuild method in my own
> DynamicBuild class
> & simply adjusting self.locks before calling the real startBuild.
> Something like:
> class DynamicBuild(Build):
>     _masterLocks = {}
>     @staticmethod
>     def find_or_create_master_lock_for_repository(repository):
>         lock = DynamicBuild._masterLocks.get(repository)
>             if lock is None:
>                 lock = locks.MasterLock(repository + ‘ submission')
>                 _masterLocks[repository] = lock
>             return lock
>     def startBuild(self, build_status, expectations, slavebuilder):
>         lock =
> DynamicBuild.find_or_create_master_lock_for_repository(build_status.getProperty(‘repository’))
>         self.locks.append(lock)
>         return Build.startBuild(self, build_status, expectations,
> slavebuilder)
> Does that seam like a workable idea?
> Is there a better approach?  I’m also thinking of overriding the
> BuildFactory so that I could
> keep the set of master locks (custom because I would need the BuildFactory
> to give the Build
> an instance of itself).
> Thanks,
> Vitali
> ------------------------------------------------------------------------------
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://p.sf.net/sfu/Zoho
> _______________________________________________
> Buildbot-devel mailing list
> Buildbot-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/buildbot-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://buildbot.net/pipermail/devel/attachments/20141017/d071aafc/attachment.html>

More information about the devel mailing list