Skip to content

Commit

Permalink
Revert "Merge pull request buildbot#1323 from delanne/IRCContact"
Browse files Browse the repository at this point in the history
This reverts commit 918e6c0, reversing
changes made to 38d595b.
  • Loading branch information
Mikhail Sobolev committed Nov 6, 2014
1 parent 918e6c0 commit c203010
Show file tree
Hide file tree
Showing 33 changed files with 480 additions and 587 deletions.
6 changes: 2 additions & 4 deletions master/buildbot/config.py
Expand Up @@ -120,8 +120,7 @@ def __init__(self):
url='http://localhost:8080/',
plugins=dict(),
auth=auth.NoAuth(),
avatar_methods=avatar.AvatarGravatar(),
logfileName='http.log',
avatar_methods=avatar.AvatarGravatar()
)

_known_config_keys = set([
Expand Down Expand Up @@ -570,8 +569,7 @@ def load_www(self, filename, config_dict):
www_cfg = config_dict['www']
allowed = set(['port', 'url', 'debug', 'json_cache_seconds',
'rest_minimum_version', 'allowed_origins', 'jsonp',
'plugins', 'auth', 'avatar_methods', 'logfileName',
'logRotateLength', 'maxRotatedFiles'])
'plugins', 'auth', 'avatar_methods'])
unknown = set(www_cfg.iterkeys()) - allowed
if unknown:
error("unknown www configuration parameter(s) %s" %
Expand Down
10 changes: 10 additions & 0 deletions master/buildbot/process/builder.py
Expand Up @@ -464,6 +464,9 @@ def buildFinished(self, build, sb):
brids = [br.id for br in build.requests]

d = self.master.data.updates.completeBuildRequests(brids, results, complete_at=complete_at)
d.addCallback(lambda _:
self._notify_completions(build.requests, results,
complete_at_epoch))
# nothing in particular to do with this deferred, so just log it if
# it fails..
d.addErrback(log.err, 'while marking build requests as completed')
Expand All @@ -473,6 +476,13 @@ def buildFinished(self, build, sb):

self.updateBigStatus()

@defer.inlineCallbacks
def _notify_completions(self, requests, results, complete_at_epoch):
# send a message for each request
for br in requests:
yield self.master.data.updates.completeBuildRequests([br.id], results,
epoch2datetime(complete_at_epoch))

def _resubmit_buildreqs(self, build):
brids = [br.id for br in build.requests]
d = self.master.data.updates.unclaimBuildRequests(brids)
Expand Down
8 changes: 2 additions & 6 deletions master/buildbot/schedulers/base.py
Expand Up @@ -213,10 +213,7 @@ def addBuildsetForSourceStampsWithDefaults(self, reason, sourcestamps,
def getCodebaseDict(self, codebase):
# Hook for subclasses to change codebase parameters when a codebase does
# not have a change associated with it.
try:
return defer.succeed(self.codebases[codebase])
except KeyError:
return defer.fail()
return self.codebases[codebase]

@defer.inlineCallbacks
def addBuildsetForChanges(self, waited_for=False, reason='',
Expand All @@ -238,8 +235,7 @@ def get_last_change_for_codebase(codebase):
if codebase not in changesByCodebase:
# codebase has no changes
# create a sourcestamp that has no changes
cb = yield self.getCodebaseDict(codebase)

cb = self.getCodebaseDict(codebase)
ss = {
'codebase': codebase,
'repository': cb['repository'],
Expand Down
105 changes: 73 additions & 32 deletions master/buildbot/schedulers/basic.py
Expand Up @@ -16,11 +16,10 @@
from buildbot import config
from buildbot import util
from buildbot.changes import changes
from buildbot.changes.filter import ChangeFilter
from buildbot.changes import filter
from buildbot.schedulers import base
from buildbot.schedulers import dependent
from buildbot.util import NotABranch
from buildbot.util.codebase import AbsoluteSourceStampsMixin
from collections import defaultdict
from twisted.internet import defer
from twisted.internet import reactor
Expand Down Expand Up @@ -82,24 +81,34 @@ def __init__(self, name, shouldntBeSet=NotSet, treeStableTimer=None,
def getChangeFilter(self, branch, branches, change_filter, categories):
raise NotImplementedError

@defer.inlineCallbacks
def activate(self):
yield base.BaseScheduler.activate(self)
yield self.startConsumingChanges(fileIsImportant=self.fileIsImportant,
change_filter=self.change_filter,
onlyImportant=self.onlyImportant)

# if we have a treeStableTimer, if there are classified changes
# out there, start their timers again
if self.treeStableTimer:
yield self.scanExistingClassifiedChanges()
def preStartConsumingChanges(self):
# Hook for subclasses to setup before startConsumingChanges().
return defer.succeed(None)

# otherwise, we don't care about classified
def activate(self):
d = base.BaseScheduler.activate(self)
d.addCallback(lambda _:
self.preStartConsumingChanges())
d.addCallback(lambda _:
self.startConsumingChanges(fileIsImportant=self.fileIsImportant,
change_filter=self.change_filter,
onlyImportant=self.onlyImportant))

# if treeStableTimer is False, then we don't care about classified
# changes, so get rid of any hanging around from previous
# configurations
if not self.treeStableTimer:
d.addCallback(lambda _:
self.master.db.schedulers.flushChangeClassifications(
self.objectid))

# otherwise, if there are classified changes out there, start their
# treeStableTimers again
else:
yield self.master.db.schedulers.flushChangeClassifications(
self.objectid)
d.addCallback(lambda _:
self.scanExistingClassifiedChanges())

return d

@defer.inlineCallbacks
def deactivate(self):
Expand Down Expand Up @@ -127,11 +136,16 @@ def gotChange(self, change, important):

timer_name = self.getTimerNameForChange(change)

# if we have a treeStableTimer
# if we have a treeStableTimer, then record the change's importance
# and:
# - for an important change, start the timer
# - for an unimportant change, reset the timer if it is running
d = self.master.db.schedulers.classifyChanges(
self.objectid, {change.number: important})

if important or self._stable_timers[timer_name]:
def fix_timer(_):
if not important and not self._stable_timers[timer_name]:
return
if self._stable_timers[timer_name]:
self._stable_timers[timer_name].cancel()

Expand All @@ -140,10 +154,8 @@ def fire_timer():
d.addErrback(log.err, "while firing stable timer")
self._stable_timers[timer_name] = self._reactor.callLater(
self.treeStableTimer, fire_timer)

# record the change's importance
return self.master.db.schedulers.classifyChanges(
self.objectid, {change.number: important})
d.addCallback(fix_timer)
return d

@defer.inlineCallbacks
def scanExistingClassifiedChanges(self):
Expand Down Expand Up @@ -178,11 +190,13 @@ def getChangeClassificationsForTimer(self, objectid, timer_name):
@util.deferredLocked('_stable_timers_lock')
@defer.inlineCallbacks
def stableTimerFired(self, timer_name):
# delete this now-fired timer, if the service has already been stopped
# then just bail out
if not self._stable_timers.pop(timer_name, None):
# if the service has already been stopped then just bail out
if not self._stable_timers[timer_name]:
return

# delete this now-fired timer
del self._stable_timers[timer_name]

classifications = \
yield self.getChangeClassificationsForTimer(self.objectid,
timer_name)
Expand All @@ -205,22 +219,49 @@ def getPendingBuildTimes(self):
return [timer.getTime() for timer in self._stable_timers.values() if timer and timer.active()]


class SingleBranchScheduler(BaseBasicScheduler, AbsoluteSourceStampsMixin):
class SingleBranchScheduler(BaseBasicScheduler):

def __init__(self, name, createAbsoluteSourceStamps=False, **kwargs):
self._lastCodebases = {}
self.createAbsoluteSourceStamps = createAbsoluteSourceStamps
BaseBasicScheduler.__init__(self, name, **kwargs)

@defer.inlineCallbacks
def preStartConsumingChanges(self):
if self.createAbsoluteSourceStamps:
# load saved codebases
d = self.getState("lastCodebases", {})

def setLast(lastCodebases):
self._lastCodebases = lastCodebases
d.addCallback(setLast)
return d
else:
return defer.succeed(None)

def gotChange(self, change, important):
d = defer.succeed(None)

if self.createAbsoluteSourceStamps:
yield self.recordChange(change)
self._lastCodebases.setdefault(change.codebase, {})
lastChange = self._lastCodebases[change.codebase].get('lastChange', -1)

codebaseDict = dict(repository=change.repository,
branch=change.branch,
revision=change.revision,
lastChange=change.number)

if change.number > lastChange:
self._lastCodebases[change.codebase] = codebaseDict
d.addCallback(lambda _:
self.setState('lastCodebases', self._lastCodebases))

yield BaseBasicScheduler.gotChange(self, change, important)
d.addCallback(lambda _:
BaseBasicScheduler.gotChange(self, change, important))
return d

def getCodebaseDict(self, codebase):
if self.createAbsoluteSourceStamps:
return AbsoluteSourceStampsMixin.getCodebaseDict(self, codebase)
return self._lastCodebases.get(codebase, self.codebases[codebase])
else:
return self.codebases[codebase]

Expand All @@ -234,7 +275,7 @@ def getChangeFilter(self, branch, branches, change_filter, categories):
"the 'branches' argument is not allowed for " +
"SingleBranchScheduler")

return ChangeFilter.fromSchedulerConstructorArgs(
return filter.ChangeFilter.fromSchedulerConstructorArgs(
change_filter=change_filter, branch=branch,
categories=categories)

Expand Down Expand Up @@ -262,7 +303,7 @@ class AnyBranchScheduler(BaseBasicScheduler):

def getChangeFilter(self, branch, branches, change_filter, categories):
assert branch is NotABranch
return ChangeFilter.fromSchedulerConstructorArgs(
return filter.ChangeFilter.fromSchedulerConstructorArgs(
change_filter=change_filter, branch=branches,
categories=categories)

Expand Down

0 comments on commit c203010

Please sign in to comment.