Heat CFN tools cannot access metadata by stack name from within nested stacks

Bug #1240892 reported by Simon Pasquier
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
JunJie Nan

Bug Description

From a nested stack, it is not possible to access resource metadata by stack name (instead of stack id).

$ cfn-get-metadata -s slurm3-Slurm-kh3clljifmov -r ClusterMetaData --credential-file /etc/cfn/cfn-credentials
DEBUG [2013-10-17 09:41:20,792] Method: GET
DEBUG [2013-10-17 09:41:20,793] Path: http://10.197.217.19:8000/v1/
DEBUG [2013-10-17 09:41:20,793] Data:
DEBUG [2013-10-17 09:41:20,793] Headers: {}
DEBUG [2013-10-17 09:41:20,793] Host: 10.197.217.19:8000
DEBUG [2013-10-17 09:41:20,794] establishing HTTP connection: kwargs={}
DEBUG [2013-10-17 09:41:20,794] Token: None
DEBUG [2013-10-17 09:41:20,794] using _calc_signature_2
DEBUG [2013-10-17 09:41:20,795] query string: AWSAccessKeyId=fcaffe6eac084608bfb7f3249861e5ac&Action=DescribeStackResource&ContentType=JSON&LogicalResourceId=ClusterMetaData&SignatureMethod=HmacSHA256&SignatureVersion=2&StackName=slurm3-Slurm-kh3clljifmov&Timestamp=2013-10-17T09%3A41%3A20Z&Version=2010-05-15
DEBUG [2013-10-17 09:41:20,795] string_to_sign: GET
10.197.217.19:8000
/v1/
AWSAccessKeyId=fcaffe6eac084608bfb7f3249861e5ac&Action=DescribeStackResource&ContentType=JSON&LogicalResourceId=ClusterMetaData&SignatureMethod=HmacSHA256&SignatureVersion=2&StackName=slurm3-Slurm-kh3clljifmov&Timestamp=2013-10-17T09%3A41%3A20Z&Version=2010-05-15
DEBUG [2013-10-17 09:41:20,795] len(b64)=44
DEBUG [2013-10-17 09:41:20,796] base64 encoded digest: f6t728WEdEa/lFizL2mep0PeZdySgpcjO7/VjTAeXRU=
DEBUG [2013-10-17 09:41:20,796] query_string: AWSAccessKeyId=fcaffe6eac084608bfb7f3249861e5ac&Action=DescribeStackResource&ContentType=JSON&LogicalResourceId=ClusterMetaData&SignatureMethod=HmacSHA256&SignatureVersion=2&StackName=slurm3-Slurm-kh3clljifmov&Timestamp=2013-10-17T09%3A41%3A20Z&Version=2010-05-15 Signature: f6t728WEdEa/lFizL2mep0PeZdySgpcjO7/VjTAeXRU=
ERROR [2013-10-17 09:41:20,983] 400 Bad Request
ERROR [2013-10-17 09:41:20,984] {"ErrorResponse": {"Error": {"Message": "A bad or out-of-range value was supplied:The Stack (slurm3-Slurm-kh3clljifmov) could not be found.", "Code": "InvalidParameterValue", "Type": "Sender"}}}
Traceback (most recent call last):
  File "/bin/cfn-get-metadata", line 83, in <module>
    metadata.retrieve()
  File "/usr/lib/python2.7/site-packages/heat_cfntools/cfntools/cfn_helper.py", line 1107, in retrieve
    self._data = self.remote_metadata()
  File "/usr/lib/python2.7/site-packages/heat_cfntools/cfntools/cfn_helper.py", line 1053, in remote_metadata
    res = client.describe_stack_resource(self.stack, self.resource)
  File "/usr/lib/python2.7/site-packages/boto/cloudformation/connection.py", line 285, in describe_stack_resource
    raise self.ResponseError(response.status, response.reason, body)
boto.exception.BotoServerError: BotoServerError: 400 Bad Request
None

$ cfn-get-metadata -s 7d21468d-f6cd-42a6-9b5c-223aea02b3de -r ClusterMetaData --credential-file /etc/cfn/cfn-credentials
DEBUG [2013-10-17 09:42:58,165] Method: GET
DEBUG [2013-10-17 09:42:58,165] Path: http://10.197.217.19:8000/v1/
DEBUG [2013-10-17 09:42:58,165] Data:
DEBUG [2013-10-17 09:42:58,165] Headers: {}
DEBUG [2013-10-17 09:42:58,166] Host: 10.197.217.19:8000
DEBUG [2013-10-17 09:42:58,166] establishing HTTP connection: kwargs={}
DEBUG [2013-10-17 09:42:58,166] Token: None
DEBUG [2013-10-17 09:42:58,166] using _calc_signature_2
DEBUG [2013-10-17 09:42:58,167] query string: AWSAccessKeyId=fcaffe6eac084608bfb7f3249861e5ac&Action=DescribeStackResource&ContentType=JSON&LogicalResourceId=ClusterMetaData&SignatureMethod=HmacSHA256&SignatureVersion=2&StackName=7d21468d-f6cd-42a6-9b5c-223aea02b3de&Timestamp=2013-10-17T09%3A42%3A58Z&Version=2010-05-15
DEBUG [2013-10-17 09:42:58,167] string_to_sign: GET
10.197.217.19:8000
/v1/
AWSAccessKeyId=fcaffe6eac084608bfb7f3249861e5ac&Action=DescribeStackResource&ContentType=JSON&LogicalResourceId=ClusterMetaData&SignatureMethod=HmacSHA256&SignatureVersion=2&StackName=7d21468d-f6cd-42a6-9b5c-223aea02b3de&Timestamp=2013-10-17T09%3A42%3A58Z&Version=2010-05-15
DEBUG [2013-10-17 09:42:58,168] len(b64)=44
DEBUG [2013-10-17 09:42:58,168] base64 encoded digest: 1wc9+D3P9tzX1Sb7Qp2muzRtxPBwzcaRTYP0y6KgpQM=
DEBUG [2013-10-17 09:42:58,168] query_string: AWSAccessKeyId=fcaffe6eac084608bfb7f3249861e5ac&Action=DescribeStackResource&ContentType=JSON&LogicalResourceId=ClusterMetaData&SignatureMethod=HmacSHA256&SignatureVersion=2&StackName=7d21468d-f6cd-42a6-9b5c-223aea02b3de&Timestamp=2013-10-17T09%3A42%3A58Z&Version=2010-05-15 Signature: 1wc9+D3P9tzX1Sb7Qp2muzRtxPBwzcaRTYP0y6KgpQM=
DEBUG [2013-10-17 09:42:59,497] {"IpAddresses": "10.0.0.15,10.0.0.14,10.0.0.16", "Size": "3"}
{"IpAddresses": "10.0.0.15,10.0.0.14,10.0.0.16", "Size": "3"}

Heat engine logs:
2013-10-17 11:44:17.815 20281 ERROR heat.openstack.common.rpc.amqp [req-a9b45168-4549-4073-a95d-5e88237309ea None demo] Exception during message handling
2013-10-17 11:44:17.815 20281 TRACE heat.openstack.common.rpc.amqp Traceback (most recent call last):
2013-10-17 11:44:17.815 20281 TRACE heat.openstack.common.rpc.amqp File "/usr/src/heat/heat/openstack/common/rpc/amqp.py", line 461, in _process_data
2013-10-17 11:44:17.815 20281 TRACE heat.openstack.common.rpc.amqp **args)
2013-10-17 11:44:17.815 20281 TRACE heat.openstack.common.rpc.amqp File "/usr/src/heat/heat/openstack/common/rpc/dispatcher.py", line 172, in dispatch
2013-10-17 11:44:17.815 20281 TRACE heat.openstack.common.rpc.amqp result = getattr(proxyobj, method)(ctxt, **kwargs)
2013-10-17 11:44:17.815 20281 TRACE heat.openstack.common.rpc.amqp File "/usr/src/heat/heat/engine/service.py", line 60, in wrapped
2013-10-17 11:44:17.815 20281 TRACE heat.openstack.common.rpc.amqp return func(self, ctx, *args, **kwargs)
2013-10-17 11:44:17.815 20281 TRACE heat.openstack.common.rpc.amqp File "/usr/src/heat/heat/engine/service.py", line 161, in identify_stack
2013-10-17 11:44:17.815 20281 TRACE heat.openstack.common.rpc.amqp raise exception.StackNotFound(stack_name=stack_name)
2013-10-17 11:44:17.815 20281 TRACE heat.openstack.common.rpc.amqp StackNotFound: The Stack (slurm3-Slurm-kh3clljifmov) could not be found.
2013-10-17 11:44:17.815 20281 TRACE heat.openstack.common.rpc.amqp
2013-10-17 11:44:17.816 20281 ERROR heat.openstack.common.rpc.common [req-a9b45168-4549-4073-a95d-5e88237309ea None demo] Returning exception The Stack (slurm3-Slurm-kh3clljifmov) could not be found. to caller

Revision history for this message
JunJie Nan (nanjj) wrote :

I have reproduced it. The embedded stack name and id in my system are:
test_embedded_stack-s-x5liqpxcuomy and 622a6f68-669d-4516-93dc-7e72a058ea0b

heat resource-list test_embedded_stack-s-x5liqpxcuomy explained stack not found.
heat resource-list 622a6f68-669d-4516-93dc-7e72a058ea0b works:
+---------------+---------------------+-----------------+----------------------+
| resource_name | resource_type | resource_status | updated_time |
+---------------+---------------------+-----------------+----------------------+
| CfnUser | AWS::IAM::User | CREATE_COMPLETE | 2013-12-11T02:51:17Z |
| WebServerKeys | AWS::IAM::AccessKey | CREATE_COMPLETE | 2013-12-11T02:51:19Z |
| e | AWS::EC2::Instance | CREATE_COMPLETE | 2013-12-11T02:51:39Z |
+---------------+---------------------+-----------------+----------------------+

I tried cfn-get-metadata also.

Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Sounds serious enough to take a long look at.

Changed in heat:
status: New → Confirmed
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

Fix proposed to branch: master
Review: https://review.openstack.org/61326

Changed in heat:
assignee: nobody → JunJie Nan (nanjj)
status: Confirmed → In Progress
Changed in heat:
milestone: none → icehouse-2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/61326
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=444bc4363a6d056b6e81935d7f58ddd743c37668
Submitter: Jenkins
Branch: master

commit 444bc4363a6d056b6e81935d7f58ddd743c37668
Author: JUN JIE NAN <email address hidden>
Date: Wed Dec 11 15:01:16 2013 +0800

    Fix stack_get_by_name does not list nested stack issue

    The nested stack's owner_id is not None. When querying a result
    filtered with owner_id=None, then nested stacks will not be
    listed. The fix is to filter stack_get_by_name by stack name only and
    add a new API stack_get_by_name_and_owner_id to filter via stack name
    and owner id.

    Change-Id: I659104f4936b567222108c211f77473ef35638c6
    Closes-Bug: #1240892

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: icehouse-2 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.