Skip to content
This repository has been archived by the owner on May 24, 2018. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/staging' into featu…
Browse files Browse the repository at this point in the history
…re/dependency-inprogress-URLs
  • Loading branch information
BarryUnity committed Sep 7, 2016
2 parents b27b533 + 7ea8e4d commit 9d26dc6
Show file tree
Hide file tree
Showing 35 changed files with 53,649 additions and 128 deletions.
6 changes: 5 additions & 1 deletion master/buildbot/buildslave/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AbstractBuildSlave(config.ReconfigurableServiceMixin, pb.Avatar,
def __init__(self, name, password, max_builds=None,
notify_on_missing=[], missing_timeout=3600,
properties={}, locks=None, keepalive_interval=3600,
friendlyName=None, os=None, eid=-1):
friendlyName=None, os=None, eid=-1, fqdn=None):
"""
@param name: botname this machine will supply when it connects
@param password: password this machine will supply when
Expand All @@ -69,12 +69,15 @@ def __init__(self, name, password, max_builds=None,
@param locks: A list of locks that must be acquired before this slave
can be used
@type locks: dictionary
@param fqdn: The fully qualified domain name (eg: slave1.unity.com) of the agent
@type fqdn: string
"""
service.MultiService.__init__(self)
self.slavename = name
self.password = password
self.friendly_name = friendlyName
self.eid = eid # External ID
self.fqdn = fqdn # Slave's full domain name

if self.friendly_name is None:
self.friendly_name = name
Expand All @@ -91,6 +94,7 @@ def __init__(self, name, password, max_builds=None,
self.slave_status = SlaveStatus(name)
self.slave_status.setFriendlyName(self.friendly_name)
self.slave_status.eid = eid
self.slave_status.fqdn = fqdn
self.slave = None # a RemoteReference to the Bot, when connected
self.slave_commands = None
self.slavebuilders = {}
Expand Down
11 changes: 8 additions & 3 deletions master/buildbot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def __init__(self):
self.autobahn_push = "false"
self.lastBuildCacheDays = 30
self.slave_debug_url = None
# This URL will only be used if no slaveManagerUrl is present in master.cfg
self.slaveManagerUrl = None

self.validation = dict(
branch=re.compile(r'^[\w.+/~-]*$'),
Expand Down Expand Up @@ -127,7 +129,7 @@ def __init__(self):
"properties", "revlink", "schedulers", "slavePortnum", "slaves",
"status", "title", "titleURL", "user_managers", "validation", "realTimeServer",
"analytics_code", "gzip", "autobahn_push", "lastBuildCacheDays",
"requireLogin", "globalFactory", "slave_debug_url",
"requireLogin", "globalFactory", "slave_debug_url", "slaveManagerUrl",
"cleanUpPeriod", "buildRequestsDays"
])

Expand Down Expand Up @@ -336,8 +338,11 @@ def copy_str_param(name, alt_key=None):
if 'autobahn_push' in config_dict:
self.autobahn_push = "true" if config_dict["autobahn_push"] else "false"

if 'slave_debug_url' in config_dict:
self.slave_debug_url = config_dict["slave_debug_url"]
copy_str_param("slave_debug_url")

copy_str_param("slaveManagerUrl")
if not self.slaveManagerUrl:
self.slaveManagerUrl = "No Slave Manager URL Configured"

copy_str_param('debugPassword')

Expand Down
55 changes: 31 additions & 24 deletions master/buildbot/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ def create_child_services(self):
self.change_svc = ChangeManager(self)
self.change_svc.setServiceParent(self)

self.scheduler_manager = SchedulerManager(self)
self.scheduler_manager.setServiceParent(self)

self.botmaster = BotMaster(self)
self.botmaster.setServiceParent(self)

self.scheduler_manager = SchedulerManager(self)
self.scheduler_manager.setServiceParent(self)

self.user_manager = UserManagerManager(self)
self.user_manager.setServiceParent(self)

Expand Down Expand Up @@ -216,6 +216,7 @@ def sigusr1(*args):
# give all services a chance to load the new configuration, rather than
# the base configuration
yield self.reconfigService(self.config)

except:
f = failure.Failure()
log.err(f, 'while starting BuildMaster')
Expand All @@ -225,12 +226,14 @@ def sigusr1(*args):

@defer.inlineCallbacks
def stopService(self):
if self.running:
yield service.MultiService.stopService(self)
# first we need to stop db_loop to avoid process request
if self.db_loop:
self.db_loop.stop()
self.db_loop = None

if self.running:
yield service.MultiService.stopService(self)


def reconfig(self):
# this method wraps doConfig, ensuring it is only ever called once at
Expand Down Expand Up @@ -301,36 +304,40 @@ def doReconfig(self):
else:
log.msg("configuration update complete")


@defer.inlineCallbacks
def reconfigService(self, new_config):
# check configured db
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']):
elif self.configured_db_url != new_config.db['db_url']:
config.error(
"Cannot change c['db']['db_url'] after the master has started",
)

# adjust the db poller
if (self.configured_poll_interval
!= new_config.db['db_poll_interval']):
if self.db_loop:
self.db_loop.stop()
self.db_loop = None
self.configured_poll_interval = new_config.db['db_poll_interval']
if self.configured_poll_interval:
self.db_loop = task.LoopingCall(self.pollDatabase)
self.db_loop.start(self.configured_poll_interval, now=False)

# setup buildbotURL
if self.configured_buildbotURL != new_config.buildbotURL:
self.configured_buildbotURL = new_config.buildbotURL
def setupMaster(_master_objectid):
self.db.mastersconfig.setupMaster(self.configured_buildbotURL, _master_objectid)
d = self.getObjectId()
d.addCallback(setupMaster)
_master_objectid = yield self.getObjectId()
yield self.db.mastersconfig.setupMaster(self.configured_buildbotURL, _master_objectid)

# stop the db pool while starting or reconfiguring the master
if self.db_loop:
self.db_loop.stop()
self.db_loop = None

# reconfigure all the services
yield config.ReconfigurableServiceMixin.reconfigService(self, new_config)
# try to start the builds after all the services are configured
self.botmaster.maybeStartBuildsForAllBuilders()

# adjust the db poller
if self.configured_poll_interval != new_config.db['db_poll_interval']:
self.configured_poll_interval = new_config.db['db_poll_interval']

return config.ReconfigurableServiceMixin.reconfigService(self,
new_config)
# resume the db poller
if self.configured_poll_interval:
self.db_loop = task.LoopingCall(self.pollDatabase)
self.db_loop.start(self.configured_poll_interval, now=False)

## informational methods

Expand Down
4 changes: 0 additions & 4 deletions master/buildbot/process/botmaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ def reconfigService(self, new_config):
yield config.ReconfigurableServiceMixin.reconfigService(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
self.maybeStartBuildsForAllBuilders()

timer.stop()


Expand Down
5 changes: 5 additions & 0 deletions master/buildbot/process/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ def stepDone(self, result, step):
terminate = True

possible_overall_result = result

if result == FAILURE:
if not step.flunkOnFailure:
possible_overall_result = SUCCESS
Expand All @@ -516,6 +517,7 @@ def stepDone(self, result, step):
possible_overall_result = FAILURE
if step.haltOnFailure:
terminate = True

elif result == WARNINGS:
if not step.warnOnWarnings:
possible_overall_result = SUCCESS
Expand All @@ -526,6 +528,9 @@ def stepDone(self, result, step):
elif result in (EXCEPTION, RETRY, DEPENDENCY_FAILURE):
terminate = True

if result in (FAILURE, EXCEPTION) and step.pauseSlaveOnFailure:
self.slavebuilder.slave.slave_status.setPaused(True)

# if we skipped this step, then don't adjust the build status
if result != SKIPPED:
self.result = worst_status(self.result, possible_overall_result)
Expand Down
4 changes: 4 additions & 0 deletions master/buildbot/process/buildrequestdistributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,10 @@ def getNextPriorityBuilder(self, queue):
log.msg("BuildRequest %d uses unknown builder %s" % (br['brid'], buildername))
continue

if not bldr.config:
log.msg("BuildRequest %d uses builder %s with no configuration" % (br['brid'], buildername))
continue

if buildername in unavailableBuilderNames and not bldr.building and br['startbrid'] is None:
continue

Expand Down
2 changes: 2 additions & 0 deletions master/buildbot/process/buildstep.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ class BuildStep(object, properties.PropertiesMixin):
flunkOnFailure = False
warnOnWarnings = False
warnOnFailure = False
pauseSlaveOnFailure = False
alwaysRun = False
doStepIf = True
hideStepIf = False
Expand All @@ -462,6 +463,7 @@ class BuildStep(object, properties.PropertiesMixin):
'flunkOnFailure',
'warnOnWarnings',
'warnOnFailure',
'pauseSlaveOnFailure',
'alwaysRun',
'progressMetrics',
'useProgress',
Expand Down
23 changes: 15 additions & 8 deletions master/buildbot/scripts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@ def isBuildBotRunning(basedir, quiet):
try:
with open(pidfile, "r") as f:
pid = int(f.read().strip())
if psutil.pid_exists(pid) and any('buildbot' in argument.lower()
for argument in psutil.Process(pid).cmdline()):
printMessage(message="buildbot is running", quiet=quiet)
return True

printMessage(
message="Removing twistd.pid, file has pid {} but buildbot is not running".format(pid),
quiet=quiet)
os.unlink(pidfile)
if isPidBuildbot(pid):
printMessage(message="buildbot is running", quiet=quiet)
return True

# If twistd.pid exists but Buildbot isn't running, then it must have been a previous Buildbot that
# unexpectedly shut down (eg: power cut). Thus, there's no reason to keep that twistd.pid around.
printMessage(
message="Removing twistd.pid, file has pid {} but buildbot is not running".format(pid),
quiet=quiet)
os.unlink(pidfile)

except Exception as ex:
print "An exception has occurred while checking twistd.pid"
Expand All @@ -68,6 +70,11 @@ def isBuildBotRunning(basedir, quiet):
return False


def isPidBuildbot(pid):
return psutil.pid_exists(pid) \
and any('buildbot' in argument.lower() for argument in psutil.Process(pid).cmdline())


def getConfigFileWithFallback(basedir, defaultName='master.cfg'):
configFile = os.path.abspath(os.path.join(basedir, defaultName))
if os.path.exists(configFile):
Expand Down
5 changes: 2 additions & 3 deletions master/buildbot/scripts/upgrade_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ def checkBasedir(config):
if runtime.platformType != 'win32': # no pids on win32
if not config['quiet']:
print "checking for running master"
pidfile = os.path.join(config['basedir'], 'twistd.pid')
if os.path.exists(pidfile):
print "'%s' exists - is this master still running?" % (pidfile,)
# isBuildBotRunning will clean up the .pid file if the build isn't running
if base.isBuildBotRunning(config['basedir'], config['quiet']):
return False

return True
Expand Down
3 changes: 3 additions & 0 deletions master/buildbot/status/slave.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self, name):
self.connect_times = []
self.master = None
self.health = 0
self.fqdn = None
self.eid = -1

def getName(self):
Expand Down Expand Up @@ -187,6 +188,8 @@ def asDict(self, include_build_steps=True, include_build_props=True):
result['runningBuilds'] = builds
result['lastMessage'] = self.lastMessageReceived()
result['health'] = self.health
result['fqdn'] = self.fqdn
result['slaveManagerUrl'] = self.master.config.slaveManagerUrl
result['eid'] = self.eid
result['graceful_shutdown'] = self.graceful_shutdown
result['paused'] = self.isPaused()
Expand Down
7 changes: 7 additions & 0 deletions master/buildbot/status/web/jsontestresults.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#
# Copyright Buildbot Team Members
import json
import re
from twisted.python import log
from os.path import join, basename, splitext
from buildbot.status.web.base import HtmlResource, path_to_builder, path_to_builders, path_to_codebases, path_to_build
Expand Down Expand Up @@ -48,6 +49,7 @@ def content(self, req, cxt):
cxt['basename'] = basename
cxt['splitext'] = splitext
cxt['selectedproject'] = project
cxt['removeTestFilter'] = removeTestFilter

try:

Expand Down Expand Up @@ -93,3 +95,8 @@ def content(self, req, cxt):

template = req.site.buildbot_service.templates.get_template("jsontestresults.html")
return template.render(**cxt)

def removeTestFilter(s):
if (s is None):
return s
return re.sub('[-]{1,2}testfilter=.*\s', '', s)
2 changes: 1 addition & 1 deletion master/buildbot/steps/python_twisted.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def __init__(self, reactor=UNSPECIFIED, python=None, trial=None,
@param kwargs: parameters. The following parameters are inherited from
L{ShellCommand} and may be useful to set: workdir,
haltOnFailure, flunkOnWarnings, flunkOnFailure,
warnOnWarnings, warnOnFailure, want_stdout, want_stderr,
warnOnWarnings, warnOnFailure, pauseSlaveOnFailure, want_stdout, want_stderr,
timeout.
"""
ShellCommand.__init__(self, **kwargs)
Expand Down
11 changes: 10 additions & 1 deletion master/buildbot/steps/slave.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,16 @@ class RemoveDirectory(SlaveBuildStep):
haltOnFailure = True
flunkOnFailure = True

def __init__(self, dir, **kwargs):
def __init__(self, dir, description=None, descriptionDone=None, **kwargs):
if description:
self.description = description
if isinstance(self.description, str):
self.description = [self.description]
if descriptionDone:
self.descriptionDone = descriptionDone
if isinstance(self.descriptionDone, str):
self.descriptionDone = [self.descriptionDone]

buildstep.BuildStep.__init__(self, **kwargs)
self.dir = dir

Expand Down
Loading

0 comments on commit 9d26dc6

Please sign in to comment.