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

Commit

Permalink
Display more user friendly message when builds gets interrupted due t…
Browse files Browse the repository at this point in the history
…o reconfiguration
  • Loading branch information
mariangemarcano committed Jun 9, 2017
1 parent e72baa5 commit 42eb6aa
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 18 deletions.
5 changes: 3 additions & 2 deletions master/buildbot/buildslave/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,9 @@ def updateRemovedBuilders(self):
if buildername in removedBuilderList:
selected_slave = build_status.getProperty('selected_slave')
result = INTERRUPTED if selected_slave and selected_slave == self.slavename else RETRY
reason = 'Slave %s reconfigured, it has been removed from this builder.' % self.slavename
yield build_status.stopBuild(reason=reason, result=result)
reason = "Slave %s reconfigured, it has been removed from this builder." % self.slavename
text = ["Katana has been reconfigured, it will automatically retry this build"]
yield build_status.stopBuild(reason=reason, result=result, text=text)

def updateSlave(self):
"""Called to add or remove builders after the slave has connected.
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/process/botmaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def stopAllBuilds(self, builder):

reason = "Builder %s has been removed" % builder.name
for build_status in builder.builder_status.currentBuilds:
yield build_status.stopBuild(reason=reason, result=INTERRUPTED)
yield build_status.stopBuild(reason=reason, result=INTERRUPTED, text=[reason])

@defer.inlineCallbacks
def reconfigServiceBuilders(self, new_config):
Expand Down
5 changes: 3 additions & 2 deletions master/buildbot/process/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def lostRemote(self, remote=None):
lock.stopWaitingUntilAvailable(self, access, d)
d.callback(None)

def stopBuild(self, reason="<no reason given>", result=None):
def stopBuild(self, reason="<no reason given>", result=None, text=None):
# the idea here is to let the user cancel a build because, e.g.,
# they realized they committed a bug and they don't want to waste
# the time building something that they know will fail. Another
Expand All @@ -579,6 +579,7 @@ def stopBuild(self, reason="<no reason given>", result=None):

# TODO: validate result is valid katana result
self.result = INTERRUPTED if result is None else result
self.text = text or self.text

if self._acquiringLock:
lock, access, d = self._acquiringLock
Expand All @@ -595,7 +596,7 @@ def allStepsDone(self):
elif self.result == EXCEPTION:
text = ["Build Caught Exception"]
elif self.result == RETRY:
text = ["Build Caught Exception, Will Retry"]
text = self.text or ["Katana will automatically retry this build"]
elif self.result == INTERRUPTED:
text = ["Build Interrupted"]
else:
Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/status/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def checkLogfiles(self):
s.checkLogfiles()

@defer.inlineCallbacks
def stopBuild(self, reason, result=None):
def stopBuild(self, reason, result=None, text=None):
if self.isFinished():
return

Expand All @@ -531,7 +531,7 @@ def stopBuild(self, reason, result=None):
if bldrc:
bldc = bldrc.getBuild(self.getNumber())
if bldc:
yield bldc.stopBuild(reason=reason, result=result)
yield bldc.stopBuild(reason=reason, result=result, text=text)

def cancelYourself(self):
self.results = CANCELED
Expand Down
23 changes: 15 additions & 8 deletions master/buildbot/steps/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,22 @@ def finishIfRunning(self, result):
if self.running:
self.finished(result)

def checkDisconection(self, result, results):
if (isinstance(results, Failure) and results.check(TriggerableSchedulerStopped)) or results == RETRY:
def setResult(self, results):
was_reconfigured = (isinstance(results, Failure) and results.check(TriggerableSchedulerStopped))
if was_reconfigured or results == RETRY:
if was_reconfigured:
self.setStatusText("Katana has been reconfigured")

result = RETRY
self.addErrorResult(results)
return result
return result

self.setStatusText("Dependency failed to build")
return DEPENDENCY_FAILURE

def setStatusText(self, text):
self.step_status.setText([text])
self.step_status.setText2(["(%s)" % text])

@defer.inlineCallbacks
def start(self):
Expand Down Expand Up @@ -208,11 +219,7 @@ def start(self):
was_failure = True

if was_exception or was_failure:
result = DEPENDENCY_FAILURE
self.step_status.setText(["Dependency failed to build."])
self.step_status.setText2(["(dependency failed to build)"])
result = self.checkDisconection(result, results)

result = self.setResult(results)
else:
result = results if results in (SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION, RETRY, CANCELED) else SUCCESS

Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/test/unit/test_process_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def acquireLocks(res=None):
self.assert_(b.currentStep is None)
self.assertEqual(b.result, RETRY)
self.assert_( ('interrupt', ('stop it',), {}) not in step.method_calls)
self.build.build_status.setText.assert_called_with(['Build Caught Exception, Will Retry'])
self.build.build_status.setText.assert_called_with(['lost', 'remote'])
self.build.build_status.setResults.assert_called_with(RETRY)

def testStopBuildWaitingForStepLocks(self):
Expand Down
4 changes: 2 additions & 2 deletions master/buildbot/test/unit/test_steps_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def test_waitForFinish_failure(self):
self.setupStep(trigger.Trigger(schedulerNames=['a'],
waitForFinish=True))
self.scheduler_a.result = FAILURE
self.expectOutcome(result=DEPENDENCY_FAILURE, status_text=['Dependency failed to build.'])
self.expectOutcome(result=DEPENDENCY_FAILURE, status_text=['Dependency failed to build'])
self.expectTriggeredWith(a=({}, {'stepname': ('Trigger', 'Trigger')}, 1))
self.expectTriggeredLinks('a')
return self.runStep(expect_waitForFinish=True)
Expand All @@ -457,7 +457,7 @@ def test_waitForFinish_exception(self):
waitForFinish=True))
self.scheduler_b.exception = True
self.expectOutcome(result=DEPENDENCY_FAILURE,
status_text=['Dependency failed to build.'])
status_text=['Dependency failed to build'])
self.expectTriggeredWith(
a=({}, {'stepname': ('Trigger', 'Trigger')}, 1),
b=({}, {'stepname': ('Trigger', 'Trigger')}, 1))
Expand Down

0 comments on commit 42eb6aa

Please sign in to comment.