Skip to content

Commit

Permalink
rename reconfigService() to reconfigServiceWithBuildbotConfig
Browse files Browse the repository at this point in the history
In the aim of simplifying the API for BuildbotService(),
we rename this method, so that the name is available for API of BuildbotService.

Next task is to convert more and more services of buildbot into BuildbotService, so that:
1) they can be abstracted from where they are configured
2) they can embed their checkConfig internally, and not in config.py

Signed-off-by: Pierre Tardy <pierre.tardy@intel.com>
  • Loading branch information
Pierre Tardy committed Dec 1, 2014
1 parent 2b1b049 commit 0b06b53
Show file tree
Hide file tree
Showing 41 changed files with 154 additions and 155 deletions.
6 changes: 3 additions & 3 deletions master/buildbot/buildslave/base.py
Expand Up @@ -210,7 +210,7 @@ def startService(self):
yield service.AsyncMultiService.startService(self)

@defer.inlineCallbacks
def reconfigService(self, new_config):
def reconfigServiceWithBuildbotConfig(self, new_config):
# Given a new BuildSlave, configure this one identically. Because
# BuildSlave objects are remotely referenced, we can't replace them
# without disconnecting the slave, yet there's no reason to do that.
Expand Down Expand Up @@ -250,8 +250,8 @@ def reconfigService(self, new_config):
# which is why the reconfig_priority is set low in this class.
yield self.updateSlave()

yield service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
yield service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)

@defer.inlineCallbacks
def stopService(self):
Expand Down
9 changes: 4 additions & 5 deletions master/buildbot/buildslave/manager.py
Expand Up @@ -85,13 +85,13 @@ def __init__(self, master):
self.slaves = {} # maps slavename to BuildSlave

@defer.inlineCallbacks
def reconfigService(self, new_config):
def reconfigServiceWithBuildbotConfig(self, new_config):

yield self.reconfigServiceSlaves(new_config)

# reconfig any newly-added change sources, as well as existing
yield service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
yield service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)

@defer.inlineCallbacks
def reconfigServiceSlaves(self, new_config):
Expand Down Expand Up @@ -186,8 +186,7 @@ def newConnection(self, conn, buildslaveName):
log.msg("Got slaveinfo from '%s'" % buildslaveName)
except Exception, e:
log.msg("Failed to communicate with slave '%s'\n"
"%s" % (buildslaveName, e)
)
"%s" % (buildslaveName, e))
defer.returnValue(False)

conn.info = info
Expand Down
8 changes: 4 additions & 4 deletions master/buildbot/changes/manager.py
Expand Up @@ -43,8 +43,8 @@ def __init__(self, master):
self.master = master

@defer.inlineCallbacks
def reconfigService(self, new_config):
timer = metrics.Timer("ChangeManager.reconfigService")
def reconfigServiceWithBuildbotConfig(self, new_config):
timer = metrics.Timer("ChangeManager.reconfigServiceWithBuildbotConfig")
timer.start()

removed, added = util.diffSets(
Expand All @@ -69,7 +69,7 @@ def reconfigService(self, new_config):
metrics.MetricCountEvent.log("num_sources", num_sources, absolute=True)

# reconfig any newly-added change sources, as well as existing
yield service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
yield service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)

timer.stop()
4 changes: 2 additions & 2 deletions master/buildbot/changes/pb.py
Expand Up @@ -133,7 +133,7 @@ def _calculatePort(self, cfg):
return port

@defer.inlineCallbacks
def reconfigService(self, new_config):
def reconfigServiceWithBuildbotConfig(self, new_config):
port = self._calculatePort(new_config)
if not port:
config.error("No port specified for PBChangeSource, and no "
Expand All @@ -144,7 +144,7 @@ def reconfigService(self, new_config):
yield self._unregister()
self._register(port)

yield service.ReconfigurableServiceMixin.reconfigService(
yield service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(
self, new_config)

def activate(self):
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/db/connector.py
Expand Up @@ -124,12 +124,12 @@ def check_current(res):

return d

def reconfigService(self, new_config):
def reconfigServiceWithBuildbotConfig(self, new_config):
# double-check -- the master ensures this in config checks
assert self.configured_url == new_config.db['db_url']

return service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
return service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)

def _doCleanup(self):
"""
Expand Down
10 changes: 5 additions & 5 deletions master/buildbot/master.py
Expand Up @@ -260,7 +260,7 @@ def sigusr1(*args):

# give all services a chance to load the new configuration, rather
# than the base configuration
yield self.reconfigService(self.config)
yield self.reconfigServiceWithBuildbotConfig(self.config)

# mark the master as active now that mq is running
yield self.data.updates.masterActive(
Expand Down Expand Up @@ -356,7 +356,7 @@ def doReconfig(self):
if name not in old_config.services:
yield new_config.services[name].setServiceParent(self)

yield self.reconfigService(new_config)
yield self.reconfigServiceWithBuildbotConfig(new_config)

except config.ConfigErrors, e:
for msg in e.errors:
Expand All @@ -376,7 +376,7 @@ def doReconfig(self):
else:
log.msg("configuration update complete")

def reconfigService(self, new_config):
def reconfigServiceWithBuildbotConfig(self, new_config):
if self.configured_db_url is None:
self.configured_db_url = new_config.db['db_url']
elif (self.configured_db_url != new_config.db['db_url']):
Expand All @@ -389,8 +389,8 @@ def reconfigService(self, new_config):
"Cannot change c['mq']['type'] after the master has started",
])

return service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
return service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)

# informational methods
def allSchedulers(self):
Expand Down
8 changes: 4 additions & 4 deletions master/buildbot/mq/connector.py
Expand Up @@ -48,18 +48,18 @@ def setup(self):
self.impl.setServiceParent(self)

# configure it (early)
self.impl.reconfigService(self.master.config)
self.impl.reconfigServiceWithBuildbotConfig(self.master.config)

# copy the methods onto this object for ease of access
self.produce = self.impl.produce
self.startConsuming = self.impl.startConsuming

def reconfigService(self, new_config):
def reconfigServiceWithBuildbotConfig(self, new_config):
# double-check -- the master ensures this in config checks
assert self.impl_type == new_config.mq['type']

return service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
return service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)

def produce(self, routing_key, data):
# will be patched after configuration to point to the running
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/mq/simple.py
Expand Up @@ -30,10 +30,10 @@ def __init__(self, master):
self.persistent_qrefs = {}
self.debug = False

def reconfigService(self, new_config):
def reconfigServiceWithBuildbotConfig(self, new_config):
self.debug = new_config.mq.get('debug', False)
return service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
return service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)

def produce(self, routingKey, data):
if self.debug:
Expand Down
8 changes: 4 additions & 4 deletions master/buildbot/process/botmaster.py
Expand Up @@ -155,16 +155,16 @@ def buildRequestAdded(key, msg):
yield service.AsyncMultiService.startService(self)

@defer.inlineCallbacks
def reconfigService(self, new_config):
timer = metrics.Timer("BotMaster.reconfigService")
def reconfigServiceWithBuildbotConfig(self, new_config):
timer = metrics.Timer("BotMaster.reconfigServiceWithBuildbotConfig")
timer.start()

# reconfigure builders
yield self.reconfigServiceBuilders(new_config)

# call up
yield service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
yield service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)

# try to start a build for every builder; this is necessary at master
# startup, and a good idea in any other case
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/process/builder.py
Expand Up @@ -90,7 +90,7 @@ def __init__(self, name, _addServices=True):
self.updateStatusService.setServiceParent(self)

@defer.inlineCallbacks
def reconfigService(self, new_config):
def reconfigServiceWithBuildbotConfig(self, new_config):
# find this builder in the config
for builder_config in new_config.builders:
if builder_config.name == self.name:
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/process/cache.py
Expand Up @@ -58,14 +58,14 @@ def get_cache(self, cache_name, miss_fn):
c = self._caches[cache_name] = lru.AsyncLRUCache(miss_fn, max_size)
return c

def reconfigService(self, new_config):
def reconfigServiceWithBuildbotConfig(self, new_config):
self.config = new_config.caches
for name, cache in self._caches.iteritems():
cache.set_max_size(new_config.caches.get(name,
self.DEFAULT_CACHE_SIZE))

return service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
return service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)

def get_metrics(self):
return dict([
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/process/debug.py
Expand Up @@ -30,7 +30,7 @@ def __init__(self, master):
self.manhole = None

@defer.inlineCallbacks
def reconfigService(self, new_config):
def reconfigServiceWithBuildbotConfig(self, new_config):
if new_config.manhole != self.manhole:
if self.manhole:
yield self.manhole.disownServiceParent()
Expand All @@ -43,8 +43,8 @@ def reconfigService(self, new_config):
yield self.manhole.setServiceParent(self)

# chain up
yield service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
yield service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)

@defer.inlineCallbacks
def stopService(self):
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/process/metrics.py
Expand Up @@ -395,7 +395,7 @@ def __init__(self):
self.getHandler(MetricCountEvent).addWatcher(
AttachedSlavesWatcher(self))

def reconfigService(self, new_config):
def reconfigServiceWithBuildbotConfig(self, new_config):
# first, enable or disable
if new_config.metrics is None:
self.disable()
Expand Down Expand Up @@ -428,8 +428,8 @@ def reconfigService(self, new_config):
self.periodic_task.start(periodic_interval)

# upcall
return util_service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
return util_service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)

def stopService(self):
self.disable()
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/process/users/manager.py
Expand Up @@ -28,7 +28,7 @@ def __init__(self, master):
self.master = master

@defer.inlineCallbacks
def reconfigService(self, new_config):
def reconfigServiceWithBuildbotConfig(self, new_config):
# this is easy - kick out all of the old managers, and add the
# new ones.

Expand All @@ -42,5 +42,5 @@ def reconfigService(self, new_config):
yield mgr.setServiceParent(self)

# reconfig any newly-added change sources, as well as existing
yield util_service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
yield util_service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)
10 changes: 5 additions & 5 deletions master/buildbot/schedulers/manager.py
Expand Up @@ -31,8 +31,8 @@ def __init__(self, master):
self.master = master

@defer.inlineCallbacks
def reconfigService(self, new_config):
timer = metrics.Timer("SchedulerManager.reconfigService")
def reconfigServiceWithBuildbotConfig(self, new_config):
timer = metrics.Timer("SchedulerManager.reconfigServiceWithBuildbotConfig")
timer.start()

old_by_name = dict((sch.name, sch) for sch in self)
Expand All @@ -56,7 +56,7 @@ def reconfigService(self, new_config):
added_names.add(n)

# compare using ComparableMixin if they don't support reconfig
elif not hasattr(old, 'reconfigService'):
elif not hasattr(old, 'reconfigServiceWithBuildbotConfig'):
if old != new:
removed_names.add(n)
added_names.add(n)
Expand Down Expand Up @@ -93,7 +93,7 @@ def reconfigService(self, new_config):
absolute=True)

# reconfig any newly-added schedulers, as well as existing
yield util_service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
yield util_service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)

timer.stop()
6 changes: 3 additions & 3 deletions master/buildbot/status/master.py
Expand Up @@ -72,7 +72,7 @@ def startService(self):
yield service.AsyncMultiService.startService(self)

@defer.inlineCallbacks
def reconfigService(self, new_config):
def reconfigServiceWithBuildbotConfig(self, new_config):
# remove the old listeners, then add the new
for sr in list(self):
yield defer.maybeDeferred(lambda:
Expand All @@ -92,8 +92,8 @@ def reconfigService(self, new_config):
yield sr.setServiceParent(self)

# reconfig any newly-added change sources, as well as existing
yield service.ReconfigurableServiceMixin.reconfigService(self,
new_config)
yield service.ReconfigurableServiceMixin.reconfigServiceWithBuildbotConfig(self,
new_config)

def stopService(self):
if self._buildset_complete_consumer:
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/test/integration/test_custom_buildstep.py
Expand Up @@ -169,7 +169,7 @@ def setUp(self):
new_config.builders.append(
config.BuilderConfig(name='test', slavename='testsl',
factory=self.factory))
yield self.builder.reconfigService(new_config)
yield self.builder.reconfigServiceWithBuildbotConfig(new_config)

self.slave = BuildSlave('bsl', 'pass')
self.slave.sendBuilderList = lambda: defer.succeed(None)
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/test/integration/test_customservices.py
Expand Up @@ -105,7 +105,7 @@ def getResultSummary(self):
class MyService(BuildbotService):
name = "myService"

def reconfigServiceWithConstructorArgs(self, num_reconfig):
def reconfigService(self, num_reconfig):
self.num_reconfig = num_reconfig
return defer.succeed(None)

Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/test/integration/test_slave_comm.py
Expand Up @@ -205,8 +205,8 @@ def addSlave(self, **kwargs):
new_config.builders = [config.BuilderConfig(name='bldr',
slavename='testslave', factory=factory.BuildFactory())]

yield self.botmaster.reconfigService(new_config)
yield self.buildslaves.reconfigService(new_config)
yield self.botmaster.reconfigServiceWithBuildbotConfig(new_config)
yield self.buildslaves.reconfigServiceWithBuildbotConfig(new_config)

# as part of the reconfig, the slave registered with the pbmanager, so
# get the port it was assigned
Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/test/integration/test_www.py
Expand Up @@ -81,14 +81,14 @@ def setUp(self):
logfileName='http.log')
master.www = wwwservice.WWWService(master)
yield master.www.startService()
yield master.www.reconfigService(master.config)
yield master.www.reconfigServiceWithBuildbotConfig(master.config)

# now that we have a port, construct the real URL and insert it into
# the config. The second reconfig isn't really required, but doesn't
# hurt.
self.url = 'http://127.0.0.1:%d/' % master.www.getPortnum()
master.config.www['url'] = self.url
yield master.www.reconfigService(master.config)
yield master.www.reconfigServiceWithBuildbotConfig(master.config)

self.master = master

Expand Down

0 comments on commit 0b06b53

Please sign in to comment.