diff --git a/heat/common/exception.py b/heat/common/exception.py index 5b0f7bac7b..af64baa0af 100644 --- a/heat/common/exception.py +++ b/heat/common/exception.py @@ -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. diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 6343cbfd98..9577eb728e 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -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 diff --git a/heat/engine/worker.py b/heat/engine/worker.py index f4d230f38c..0eb2fa435f 100644 --- a/heat/engine/worker.py +++ b/heat/engine/worker.py @@ -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, diff --git a/heat/tests/engine/test_engine_worker.py b/heat/tests/engine/test_engine_worker.py index 160e1b7fad..16d3a83956 100644 --- a/heat/tests/engine/test_engine_worker.py +++ b/heat/tests/engine/test_engine_worker.py @@ -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) diff --git a/heat/tests/test_resource.py b/heat/tests/test_resource.py index f668e70966..068597620c 100644 --- a/heat/tests/test_resource.py +++ b/heat/tests/test_resource.py @@ -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." %