Use EntityNotFound instead of SyncPointNotFound

Unify NotFound exception with Entitynotfound.

Change-Id: I0c69596eb332b768a606c7b11ef768c4a1404d2e
Depends-On: I782c372723f188bab38656e5b7cc401d23808ffb
changes/44/262944/5
ricolin 7 years ago committed by Rico Lin
parent b445f42ff0
commit 0c8d9145da
  1. 11
      heat/engine/sync_point.py
  2. 35
      heat/engine/worker.py
  3. 3
      heat/tests/engine/test_engine_worker.py

@ -16,7 +16,7 @@ import ast
from oslo_log import log as logging
import six
from heat.common.i18n import _
from heat.common import exception
from heat.objects import sync_point as sync_point_object
LOG = logging.getLogger(__name__)
@ -49,7 +49,7 @@ def get(context, entity_id, traversal_id, is_update):
is_update)
if sync_point is None:
key = (entity_id, traversal_id, is_update)
raise SyncPointNotFound(key)
raise exception.EntityNotFound(entity='Sync Point', name=key)
return sync_point
@ -136,10 +136,3 @@ def sync(cnxt, entity_id, current_traversal, is_update, propagate,
LOG.debug('[%s] Ready %s: Got %s',
key, entity_id, _dump_list(input_data))
propagate(entity_id, serialize_input_data(input_data))
class SyncPointNotFound(Exception):
"""Raised when resource update requires replacement."""
def __init__(self, sync_point):
msg = _("Sync Point %s not found") % (sync_point, )
super(Exception, self).__init__(six.text_type(msg))

@ -224,8 +224,11 @@ class WorkerService(service.Service):
propagate_check_resource(cnxt, self._rpc_client, resource_id,
current_traversal, predecessors, key,
None, key[1], None)
except sync_point.SyncPointNotFound:
pass
except exception.EntityNotFound as e:
if e.entity == "Sync Point":
pass
else:
raise
def _initiate_propagate_resource(self, cnxt, resource_id,
current_traversal, is_update, rsrc,
@ -266,18 +269,22 @@ class WorkerService(service.Service):
check_stack_complete(cnxt, stack, current_traversal,
resource_id, deps, is_update)
except sync_point.SyncPointNotFound:
# Reload the stack to determine the current traversal, and check
# the SyncPoint for the current node to determine if it is ready.
# If it is, then retrigger the current node with the appropriate
# data for the latest traversal.
stack = parser.Stack.load(cnxt, stack_id=rsrc.stack.id)
if current_traversal == stack.current_traversal:
LOG.debug('[%s] Traversal sync point missing.',
current_traversal)
return
self._retrigger_check_resource(cnxt, is_update, resource_id, stack)
except exception.EntityNotFound as e:
if e.entity == "Sync Point":
# Reload the stack to determine the current traversal, and
# check the SyncPoint for the current node to determine if
# it is ready. If it is, then retrigger the current node
# with the appropriate data for the latest traversal.
stack = parser.Stack.load(cnxt, stack_id=rsrc.stack.id)
if current_traversal == stack.current_traversal:
LOG.debug('[%s] Traversal sync point missing.',
current_traversal)
return
self._retrigger_check_resource(cnxt, is_update,
resource_id, stack)
else:
raise
@context.request_context
def check_resource(self, cnxt, resource_id, current_traversal, data,

@ -385,7 +385,8 @@ class CheckWorkflowUpdateTest(common.HeatTestCase):
key = sync_point.make_key(self.resource.id,
self.stack.current_traversal,
self.is_update)
mock_pcr.side_effect = sync_point.SyncPointNotFound(key)
mock_pcr.side_effect = exception.EntityNotFound(entity='Sync Point',
name=key)
updated_stack = stack.Stack(self.ctx, self.stack.name, self.stack.t,
self.stack.id,
current_traversal='some_newy_trvl_uuid')

Loading…
Cancel
Save