Don't get resource twice in resource_signal()
For no reason at all, we were calling Stack.resource_get() twice in handle_signal(). In the worst case, this function does a database query that loads every resource. Change-Id: I9e3f1e77146c71ae35a0896f915f6f9c9fac3fd3 Related-Bug: #1635610
This commit is contained in:
parent
2ced86836e
commit
d45de801b2
|
@ -1804,15 +1804,6 @@ class EngineService(service.ServiceBase):
|
|||
access_key = ec2_creds.get('access')
|
||||
return stack.access_allowed(access_key, resource_name)
|
||||
|
||||
def _verify_stack_resource(self, stack, resource_name):
|
||||
resource = stack.resource_get(resource_name)
|
||||
if not resource:
|
||||
raise exception.ResourceNotFound(resource_name=resource_name,
|
||||
stack_name=stack.name)
|
||||
|
||||
if resource.id is None:
|
||||
raise exception.ResourceNotAvailable(resource_name=resource_name)
|
||||
|
||||
@context.request_context
|
||||
def describe_stack_resource(self, cnxt, stack_identity, resource_name,
|
||||
with_attr=None):
|
||||
|
@ -1864,9 +1855,13 @@ class EngineService(service.ServiceBase):
|
|||
# signal doesn't have permission to read the secret key of
|
||||
# the user associated with the cfn-credentials file
|
||||
stack = parser.Stack.load(cnxt, stack=s, use_stored_context=True)
|
||||
self._verify_stack_resource(stack, resource_name)
|
||||
|
||||
rsrc = stack.resource_get(resource_name)
|
||||
if rsrc is None:
|
||||
raise exception.ResourceNotFound(resource_name=resource_name,
|
||||
stack_name=stack.name)
|
||||
if rsrc.id is None:
|
||||
raise exception.ResourceNotAvailable(resource_name=resource_name)
|
||||
|
||||
if callable(rsrc.signal):
|
||||
rsrc._signal_check_action()
|
||||
|
|
Loading…
Reference in New Issue