can't make a template with no resources

Bug #1339893 reported by Angus Salkeld
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Angus Salkeld

Bug Description

This template:

"
heat_template_version: 2013-05-23
parameters:
resources:
outputs:
"

causes this error on the client:
ERROR: 'NoneType' object has no attribute 'items' (HTTP 400)

and this exception in the engine:
['Traceback (most recent call last):\n', ' File "/usr/local/lib/python2.7/dist-packages/oslo/messaging/rpc/dispatcher.py", line 134, in _dispatch_and_reply\n incoming.message))\n', ' File "/usr/local/lib/python2.7/dist-packages/oslo/messaging/rpc/dispatcher.py", line 177, in _dispatch\n return self._do_dispatch(endpoint, method, ctxt, args)\n', ' File "/usr/local/lib/python2.7/dist-packages/oslo/messaging/rpc/dispatcher.py", line 123, in _do_dispatch\n result = getattr(endpoint, method)(ctxt, **new_args)\n', ' File "/opt/stack/heat/heat/engine/service.py", line 63, in wrapped\n return func(self, ctx, *args, **kwargs)\n', ' File "/opt/stack/heat/heat/engine/service.py", line 568, in create_stack\n stack.validate()\n', ' File "/opt/stack/heat/heat/engine/parser.py", line 409, in validate\n dup_names = set(self.parameters.keys()) & set(self.keys())\n', ' File "/usr/lib/python2.7/_abcoll.py", line 366, in keys\n return list(self)\n', ' File "/opt/stack/heat/heat/engine/parser.py", line 309, in __iter__\n return iter(self.resources)\n', ' File "/opt/stack/heat/heat/engine/parser.py", line 142, in resources\n self.t.resource_definitions(self).items())\n', ' File "/opt/stack/heat/heat/engine/hot/template.py", line 217, in resource_definitions\n resources = self.t.get(self.RESOURCES, {}).items()\n', "AttributeError: 'NoneType' object has no attribute 'items'\n"]

Angus Salkeld (asalkeld)
Changed in heat:
importance: Undecided → Medium
Angus Salkeld (asalkeld)
Changed in heat:
assignee: nobody → Angus Salkeld (asalkeld)
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/105894

Changed in heat:
status: New → In Progress
Revision history for this message
Steven Hardy (shardy) wrote :

Interesting, is this specific to HOT? As we have a tempest test which, in theory, should have caught this, at least for CFN templates:

https://github.com/openstack/tempest/blob/master/tempest/api/orchestration/stacks/test_stacks.py#L41

Revision history for this message
Angus Salkeld (asalkeld) wrote :

It depends on your definition of empty and whether you use json or yaml.
see: https://review.openstack.org/#/c/105894/5/heat/tests/test_empty_stack.py

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

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

commit f6894260caa29c883a930095b086a3710fd86b8c
Author: Angus Salkeld <email address hidden>
Date: Mon Jul 14 21:26:43 2014 +1000

    Make sure we can create an empty template

    The initial bug was for HOT, but this fixes the same issue
    in CFN too.

    1) all calls to template[section] should return {} and not
       None by default (hot was correct, but not cfn)
    2) the validate needs to access the raw template "self.t" so
       make sure we have a similar logic there too.
    3) when warning for zero resources, look for len(resoruces) == 0 not
       None.

    Change-Id: Iee6e2abbf13173c17d92f47b8a7efe207c29a984
    Closes-bug: #1339893

Changed in heat:
status: In Progress → Fix Committed
Changed in heat:
milestone: none → juno-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: juno-2 → 2014.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.