Bad environment file results in un-deletable stack

Bug #1227816 reported by Steven Hardy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Critical
Steven Hardy

Bug Description

Not quite sure how this happened yet, but if an environment file gets to the engine without resolving the local file:/// references, the stack becomes permanently wedged, you can't even do stack-list anymore.

My environment:

# cat env_minimal.yaml
resource_registry:
    # Define a custom resource type based on a template
    "My::Custom::Server": file:///tmp/hot_minimal.yaml

Which for some reason was not expanded by heatclient (still looking into why). This means you could also craft an API request with an invalid environment content to have a similar effect.

We get a 400 response, but the stack is left stuck in CREATE, FAILED state

| 95d75439-1113-4ab2-aef8-58466598e2ba | 2013-09-19 17:10:52 | 2013-09-19 17:10:54 | test_stack | 66 | 66 | admin | NULL | FAILED | Resource create failed: Error: Resource create failed: Error: Creation of server test_stack-wordpress_instance-lmnpdgsrn6tk-wordpress_instance-fzbovybrsqjz failed. | {"parameters": {}, "resource_registry": {"My::Custom::Server": "file:///tmp/hot_minimal.yaml", "resources": {}}} | 60 | 2e8a9864067140ecb85f034909d7f10a | 1 | CREATE | NULL |

engine.log

2013-09-19 18:22:30.884 7560 INFO heat.engine.environment [-] Registering My::Custom::Server -> file:///tmp/hot_minimal.yaml
2013-09-19 18:22:30.884 7560 INFO heat.common.urlfetch [-] Fetching data from file:///tmp/hot_minimal.yaml
2013-09-19 18:22:30.884 7560 ERROR heat.openstack.common.rpc.amqp [-] Exception during message handling
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp Traceback (most recent call last):
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/openstack/common/rpc/amqp.py", line 461, in _process_data
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp **args)
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/openstack/common/rpc/dispatcher.py", line 172, in dispatch
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp result = getattr(proxyobj, method)(ctxt, **kwargs)
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/service.py", line 56, in wrapped
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp return func(self, ctx, *args, **kwargs)
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/service.py", line 146, in identify_stack
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp stack = parser.Stack.load(cnxt, stack=s)
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/parser.py", line 171, in load
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp parent_resource, owner_id=stack.owner_id)
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/parser.py", line 108, in __init__
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp for (name, data) in template_resources.items())
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/parser.py", line 108, in <genexpr>
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp for (name, data) in template_resources.items())
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/resource.py", line 133, in __new__
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp return ResourceClass(name, json, stack)
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/resources/template_resource.py", line 53, in __init__
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp tmpl = template.Template(self.parsed_nested)
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/resources/template_resource.py", line 97, in parsed_nested
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp self._parsed_nested = template_format.parse(self.template_data)
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/resources/template_resource.py", line 109, in template_data
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp (self.template_name, str(r_exc)))
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp ValueError: Could not fetch remote template 'file:///tmp/hot_minimal.yaml': Invalid URL scheme file
2013-09-19 18:22:30.884 7560 TRACE heat.openstack.common.rpc.amqp
2013-09-19 18:22:30.885 7560 ERROR heat.openstack.common.rpc.common [-] Returning exception Could not fetch remote template 'file:///tmp/hot_minimal.yaml': Invalid URL scheme file to caller
2013-09-19 18:22:30.885 7560 ERROR heat.openstack.common.rpc.common [-] ['Traceback (most recent call last):\n', ' File "/usr/lib/python2.7/site-packages/heat/openstack/common/rpc/amqp.py", line 461, in _process_data\n **args)\n', ' File "/usr/lib/python2.7/site-packages/heat/openstack/common/rpc/dispatcher.py", line 172, in dispatch\n result = getattr(proxyobj, method)(ctxt, **kwargs)\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/service.py", line 56, in wrapped\n return func(self, ctx, *args, **kwargs)\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/service.py", line 146, in identify_stack\n stack = parser.Stack.load(cnxt, stack=s)\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/parser.py", line 171, in load\n parent_resource, owner_id=stack.owner_id)\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/parser.py", line 108, in __init__\n for (name, data) in template_resources.items())\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/parser.py", line 108, in <genexpr>\n for (name, data) in template_resources.items())\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/resource.py", line 133, in __new__\n return ResourceClass(name, json, stack)\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/resources/template_resource.py", line 53, in __init__\n tmpl = template.Template(self.parsed_nested)\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/resources/template_resource.py", line 97, in parsed_nested\n self._parsed_nested = template_format.parse(self.template_data)\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/resources/template_resource.py", line 109, in template_data\n (self.template_name, str(r_exc)))\n', "ValueError: Could not fetch remote template 'file:///tmp/hot_minimal.yaml': Invalid URL scheme file\n"]
2013-09-19 18:22:30.885 7560 DEBUG heat.openstack.common.rpc.amqp [-] UNIQUE_ID is fda81d87ad494aca972103ce8e45e1a5. _add_unique_id /usr/lib/python2.7/site-packages/heat/openstack/common/rpc/amqp.py:341

Steven Hardy (shardy)
Changed in heat:
status: New → Triaged
importance: Undecided → Critical
milestone: none → havana-rc1
assignee: nobody → Steven Hardy (shardy)
Steven Hardy (shardy)
Changed in heat:
status: Triaged → In Progress
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/47484

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/47484
Committed: http://github.com/openstack/heat/commit/c6b1c61376de61445612370ae5eb8f97e2bcfc43
Submitter: Jenkins
Branch: master

commit c6b1c61376de61445612370ae5eb8f97e2bcfc43
Author: Steven Hardy <email address hidden>
Date: Thu Sep 19 22:31:16 2013 +0100

    Tolerate bad environment until validation

    Currently if we get a bad environment for a template_resource,
    it causes an exception in the resource constructor, which does cause
    the stack create to fail, but also all subsequent operations too.

    By tolerating the error in the constructor, we can catch it instead at
    validation time.

    Change-Id: Ia971d8f1c50ca6f265ec36ea564aeba1638de541
    Closes-Bug: 1227816

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: havana-rc1 → 2013.2
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.