Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reraise error if remoteGetWorkerInfo() fails #2221

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions master/buildbot/test/unit/test_worker_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,14 @@ def test_reconfigServiceWorkers_class_changes(self):

# worker *was* replaced (different class)
self.assertIdentical(self.workers.workers['worker1'], worker_new)

@defer.inlineCallbacks
def test_newConnection_remoteGetWorkerInfo_failure(self):
class Error(RuntimeError):
pass

conn = mock.Mock()
conn.remoteGetWorkerInfo = mock.Mock(
return_value=defer.fail(Error()))
yield self.assertFailure(
self.workers.newConnection(conn, "worker"), Error)
7 changes: 2 additions & 5 deletions master/buildbot/worker/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# Copyright Buildbot Team Members
from twisted.internet import defer
from twisted.python import log
from twisted.python.failure import Failure

from buildbot.process.measured_service import MeasuredBuildbotServiceManager
from buildbot.util import misc
Expand Down Expand Up @@ -110,9 +109,7 @@ def newConnection(self, conn, workerName):
old_conn.remotePrint("master got a duplicate connection"))
# if we get here then old connection is still alive, and new
# should be rejected
defer.returnValue(
Failure(RuntimeError("rejecting duplicate worker"))
)
raise RuntimeError("rejecting duplicate worker")
except defer.CancelledError:
old_conn.loseConnection()
log.msg("Connected worker '%s' ping timed out after %d seconds"
Expand All @@ -131,7 +128,7 @@ def newConnection(self, conn, workerName):
except Exception as e:
log.msg("Failed to communicate with worker '%s'\n"
"%s" % (workerName, e))
defer.returnValue(False)
raise

conn.info = info
self.connections[workerName] = conn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raise

works better

Expand Down