Handle exception when worker unlocks already unlocked resource
The same exception is handled similary elsewhere. This avoids a corner
case where the worker ends up throwing an exception here and blocking
the state machine from processing future messages.
(backported to kilo from 6cf7784f51
)
Change-Id: I14709faac9228797f9ca043e45c550449437e561
Closes-bug: #1536901
This commit is contained in:
parent
d35432a5d3
commit
e980378e68
|
@ -453,3 +453,27 @@ class TestNormalizeUUID(unittest.TestCase):
|
|||
'ac194fc5f317412e8611fb290629f624'
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class TestReleaseLock(WorkerTestBase):
|
||||
def test__release_router_lock(self):
|
||||
router_id = '0ae77286-c0d6-11e5-9181-525400137dfc'
|
||||
fake_lock = mock.Mock(release=mock.Mock())
|
||||
|
||||
self.w._router_locks = {
|
||||
router_id: fake_lock
|
||||
}
|
||||
fake_sm = mock.Mock(router_id=router_id)
|
||||
self.w._release_router_lock(fake_sm)
|
||||
self.assertTrue(fake_lock.release.called)
|
||||
|
||||
def test__release_router_lock_unlocked(self):
|
||||
router_id = '0ae77286-c0d6-11e5-9181-525400137dfc'
|
||||
fake_lock = mock.Mock(release=mock.Mock())
|
||||
fake_lock.release.side_effect = threading.ThreadError()
|
||||
self.w._router_locks = {
|
||||
router_id: fake_lock
|
||||
}
|
||||
fake_sm = mock.Mock(router_id=router_id)
|
||||
# just ensure we dont raise
|
||||
self.w._release_router_lock(fake_sm)
|
||||
|
|
|
@ -364,7 +364,11 @@ class Worker(object):
|
|||
LOG.debug('%s is already in the work queue', sm.router_id)
|
||||
|
||||
def _release_router_lock(self, sm):
|
||||
self._router_locks[sm.router_id].release()
|
||||
try:
|
||||
self._router_locks[sm.router_id].release()
|
||||
except threading.ThreadError:
|
||||
# Already unlocked, that's OK.
|
||||
pass
|
||||
|
||||
def report_status(self, show_config=True):
|
||||
if show_config:
|
||||
|
|
Loading…
Reference in New Issue