Merge "Use EntityNotFound instead of SyncPointNotFound"

This commit is contained in:
Jenkins 2016-03-30 07:35:50 +00:00 committed by Gerrit Code Review
commit 9d03183ab5
3 changed files with 24 additions and 23 deletions

View File

@ -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))

View File

@ -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
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)
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,

View File

@ -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')