Skip to content

Commit

Permalink
Only send messages about deactivated masters if they're actually deac…
Browse files Browse the repository at this point in the history
…tivated

As pointed out by tomprince
  • Loading branch information
djmitche committed Oct 14, 2012
1 parent 9b76d63 commit 1a6e90a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 6 additions & 5 deletions master/buildbot/data/masters.py
Expand Up @@ -84,12 +84,13 @@ def masterActive(self, name, masterid, _reactor=reactor):
continue

# mark the master inactive, and send a message on its behalf
yield self.master.db.masters.setMasterState(
deactivated = yield self.master.db.masters.setMasterState(
masterid=m['id'], active=False, _reactor=_reactor)
self.produceEvent(
dict(masterid=m['id'], name=m['name'],
active=False),
'stopped')
if deactivated:
self.produceEvent(
dict(masterid=m['id'], name=m['name'],
active=False),
'stopped')

@base.updateMethod
@defer.inlineCallbacks
Expand Down
6 changes: 5 additions & 1 deletion master/buildbot/test/unit/test_data_masters.py
Expand Up @@ -107,6 +107,8 @@ def test_masterActive(self):
last_active=0),
fakedb.Master(id=14, name='other', active=1,
last_active=0),
fakedb.Master(id=15, name='other', active=1,
last_active=0),
])

# initial checkin
Expand Down Expand Up @@ -135,8 +137,10 @@ def test_masterActive(self):
])
self.master.mq.productions = []

# re-checkin after over 10 minutes, and see #14 deactivated
# re-checkin after over 10 minutes, and see #14 deactivated; #15
# gets deactivated by another master, so it's not included here
clock.advance(600)
yield self.master.db.masters.markMasterInactive(15)
yield self.rtype.masterActive(
u'myname', masterid=13, _reactor=clock)
master = yield self.master.db.masters.getMaster(14)
Expand Down

0 comments on commit 1a6e90a

Please sign in to comment.