Move Resource exceptions to common module (4)
It is convenient to have all exceptions in exception module. Also it is reduces namespace cluttering of resource module and decreases the number of dependencies in other modules (we do not need to import resource in some cases for now). UpdateInProgress exception is moved in this patch. Change-Id: If694c264639bbce5334e1e6e7403b225ce1d3aee
This commit is contained in:
parent
6d41bcc1d3
commit
f1b2d9add5
|
@ -414,6 +414,12 @@ class ResourceInError(HeatException):
|
|||
**kwargs)
|
||||
|
||||
|
||||
class UpdateInProgress(Exception):
|
||||
def __init__(self, resource_name='Unknown'):
|
||||
msg = _("The resource %s is already being updated.") % resource_name
|
||||
super(Exception, self).__init__(six.text_type(msg))
|
||||
|
||||
|
||||
class HTTPExceptionDisguise(Exception):
|
||||
"""Disguises HTTP exceptions so they can be handled by the webob fault
|
||||
application in the wsgi pipeline.
|
||||
|
|
|
@ -61,12 +61,6 @@ class NoActionRequired(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class UpdateInProgress(Exception):
|
||||
def __init__(self, resource_name='Unknown'):
|
||||
msg = _("The resource %s is already being updated.") % resource_name
|
||||
super(Exception, self).__init__(six.text_type(msg))
|
||||
|
||||
|
||||
@six.python_2_unicode_compatible
|
||||
class Resource(object):
|
||||
ACTIONS = (
|
||||
|
@ -1310,7 +1304,7 @@ class Resource(object):
|
|||
raise
|
||||
|
||||
if not updated_ok:
|
||||
ex = UpdateInProgress(self.name)
|
||||
ex = exception.UpdateInProgress(self.name)
|
||||
LOG.exception('atomic:%s engine_id:%s/%s' % (
|
||||
rs.atomic_key, rs.engine_id, engine_id))
|
||||
raise ex
|
||||
|
|
|
@ -172,7 +172,7 @@ class WorkerService(service.Service):
|
|||
self.engine_id, stack.time_remaining())
|
||||
|
||||
return True
|
||||
except resource.UpdateInProgress:
|
||||
except exception.UpdateInProgress:
|
||||
if self._try_steal_engine_lock(cnxt, rsrc.id):
|
||||
rpc_data = sync_point.serialize_input_data(resource_data)
|
||||
self._rpc_client.check_resource(cnxt,
|
||||
|
|
|
@ -183,7 +183,7 @@ class CheckWorkflowUpdateTest(common.HeatTestCase):
|
|||
@mock.patch.object(worker.WorkerService, '_try_steal_engine_lock')
|
||||
def test_is_update_traversal_raise_update_inprogress(
|
||||
self, mock_tsl, mock_cru, mock_crc, mock_pcr, mock_csc, mock_cid):
|
||||
mock_cru.side_effect = resource.UpdateInProgress
|
||||
mock_cru.side_effect = exception.UpdateInProgress
|
||||
self.worker.engine_id = 'some-thing-else'
|
||||
mock_tsl.return_value = True
|
||||
self.worker.check_resource(
|
||||
|
@ -501,7 +501,7 @@ class CheckWorkflowCleanupTest(common.HeatTestCase):
|
|||
|
||||
def test_is_cleanup_traversal_raise_update_inprogress(
|
||||
self, mock_cru, mock_crc, mock_pcr, mock_csc, mock_cid):
|
||||
mock_crc.side_effect = resource.UpdateInProgress
|
||||
mock_crc.side_effect = exception.UpdateInProgress
|
||||
self.worker.check_resource(
|
||||
self.ctx, self.resource.id, self.stack.current_traversal, {},
|
||||
self.is_update, None)
|
||||
|
|
|
@ -1673,7 +1673,7 @@ class ResourceTest(common.HeatTestCase):
|
|||
|
||||
res_data = {(1, True): {u'id': 4, u'name': 'A', 'attrs': {}},
|
||||
(2, True): {u'id': 3, u'name': 'B', 'attrs': {}}}
|
||||
ex = self.assertRaises(resource.UpdateInProgress,
|
||||
ex = self.assertRaises(exception.UpdateInProgress,
|
||||
res.update_convergence,
|
||||
'template_key',
|
||||
res_data, 'engine-007',
|
||||
|
@ -1744,7 +1744,7 @@ class ResourceTest(common.HeatTestCase):
|
|||
rs = resource_objects.Resource.get_obj(self.stack.context, res.id)
|
||||
rs.update_and_save({'engine_id': 'not-this'})
|
||||
self._assert_resource_lock(res.id, 'not-this', None)
|
||||
ex = self.assertRaises(resource.UpdateInProgress,
|
||||
ex = self.assertRaises(exception.UpdateInProgress,
|
||||
res.delete_convergence,
|
||||
1, {}, 'engine-007', self.dummy_timeout)
|
||||
msg = ("The resource %s is already being updated." %
|
||||
|
|
Loading…
Reference in New Issue