[Buildbot-devel] Scheduler maintenance windows?

Brian Warner warner-buildbot at lothar.com
Wed Apr 26 02:10:20 UTC 2006


> I'm considering a patch to Scheduler to make it avoid scheduling  
> anything during a specific window every night.

> I suppose I could crank up the timeout on that step a *lot*, but I  
> think it's better to just queue builds until the known window has  
> ended. Either by time or by the Perforce server's pre- and post- 
> backup scripts notifying buildbot in some way.

Yeah, I'd probably go with the custom Scheduler route. Something like this:

class BlackoutWindowScheduler(scheduler.Scheduler):
    def __init__(self, *args, **kwargs):
        scheduler.Scheduler.__init__(self, *args, **kwargs)
        self.pending_buildsets = []
        self.pending_timer = None

    def submit(self, bs):
        now = time.time()
        if not self.areInABlackoutWindow(now):
            scheduler.Scheduler.submit(self, bs)
            return
        self.pending_buildsets.append(bs)
        if not self.pending_timer:
            when = self.getEndOfBlackoutWindow()
            self.pending_timer = reactor.callLater(when - now,
                                                   self.blackoutOver)

    def blackoutOver(self):
        self.pending_timer = None
        for bs in self.pending_buildsets:
            scheduler.Scheduler.submit(self, bs)
        self.pending_buildsets = []

    def stopService(self):
        if self.pending_timer:
            self.pending_timer.cancel()
            self.pending_timer = None
        return scheduler.Scheduler.stopService(self)


You'd probably want to parameterize the start and finish of the blackout
window, and make sure the window starts at least a checkout time before the
actual Perforce lockout starts (so that you probably won't have a build still
running when Perforce starts being uncooperative).

I suppose a cleaner way (from the point of view of the user, but not
necessarily the implentor) to do this would be to have a new kind of Lock
object, the TimeLock. You could create a TimeLock with a description of when
it opens up (in this case, all day long except for the nightly blackout
window), and make the checkout step or perhaps the whole Build try to claim
the lock. It wouldn't be quite the same as the regular SlaveLock and
MasterLocks, because the timer wouldn't be allowed to "claim" the lock while
a build is running, but otherwise the code would probably be pretty similar.

It would also be nice to have a way to display *why* a build was waiting for
a lock, specifically which locks it was waiting for. The big yellow rectangle
that shows up when a build has "started" but the first step hasn't been
allowed to commence is kind of ugly.
  

cheers,
 -Brian




More information about the devel mailing list