heat validates successfully empty template files

Bug #1278090 reported by Removed by request
6
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Low
Sergey Kraynev

Bug Description

From the documentation in http://docs.openstack.org/user-guide/content/heat-stack-create.html:

"
You can also use the stack-create command to validate a template file without creating a stack from it.
To do so, run the following command:
$ heat stack-create mystack --template-file=/PATH_TO_HEAT_TEMPLATES/WordPress_Single_Instance.template
"

However trying to validate empty files or even null, will return a success:

# heat stack-create test234 --template-file=/dev/null
+--------------------------------------+------------+-----------------+----------------------+
| id | stack_name | stack_status | creation_time |
+--------------------------------------+------------+-----------------+----------------------+
| f9e37e85-9c4b-4422-943c-a593c75d677f | test123 | CREATE_COMPLETE | 2014-02-09T13:38:42Z |

# tail /var/log/heat/engine.log
2014-02-09 15:54:26.364 1778 INFO heat.engine.service [req-f9e37e85-9c4b-4422-943c-a593c75d677f ***** *****] template is {u'Parameters': {}, u'Outputs': {}, u'HeatTemplateFormatVersion': u'2012-12-12', u'Mappings': {}, u'Resources': {}}

# mysql
MariaDB [(none)]> use heat
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [heat]> select * from stack where name='test123'\G;
*************************** 1. row ***************************
              id: f9e37e85-9c4b-4422-943c-a593c75d677f
      created_at: 2014-02-09 13:38:42
      updated_at: 2014-02-09 13:38:42
            name: test123
 raw_template_id: 160
   user_creds_id: 160
        username: admin
        owner_id: NULL
          status: COMPLETE
   status_reason: Stack create completed successfully
      parameters: {"parameters": {}, "resource_registry": {"resources": {}}}
         timeout: 60
          tenant: 0e8b6030e87f49be8ae68fc37649a986
disable_rollback: 1
          action: CREATE
      deleted_at: NULL
1 row in set (0.00 sec)

Other info:
# cat /etc/redhat-release
Fedora release 20 (Heisenbug)

# uname -a
Linux ***domain*** 3.12.9-301.fc20.x86_64 #1 SMP Wed Jan 29 15:56:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

# heat --version
0.2.6

# rpm -qa | grep heat
openstack-heat-engine-2014.1-0.4.b1.fc21.noarch
python-heatclient-0.2.6-3.fc21.noarch
openstack-heat-common-2014.1-0.4.b1.fc21.noarch
openstack-heat-api-2014.1-0.4.b1.fc21.noarch

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

I think there are a number of things like this that might best be handed with a system of warnings, rather than failures. It is valid YAML, and just because it has no parameters, resources, or outputs, doesn't mean it is "invalid". Heat is just following orders. It is rather obvious when one looks at the resulting stack that it is not really useful.

Changed in heat:
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Removed by request (removed3381998) wrote :

So there is at least one issue here, and that's the stack creation itself. Reading from the link I provided, when just handing heat a template file, it should only validate the template, not create a stack.

Revision history for this message
Clint Byrum (clint-fewbar) wrote : Re: [Bug 1278090] Re: heat validates successfully empty template files

Excerpts from Amit Ugol's message of 2014-02-10 05:54:29 UTC:
> So there is at least one issue here, and that's the stack creation
> itself. Reading from the link I provided, when just handing heat a
> template file, it should only validate the template, not create a stack.
>

I did not get that from the description you posted.

That is a separate bug from validating successfully. I agree that we
shouldn't create a stack when template-validate is used. But the examples
you gave were only stack-create.

Revision history for this message
Removed by request (removed3381998) wrote :

I opened this bug thinking that empty templates should not be validated as they create 'bad' stacks but then I saw the validation thing (as posted) and added that to the description as well. I know empty templates are YAML valid but IMO that does not mean that they are 'heat valid' as in heat will not be able to do anything with them, rendering them useless.
If needs be I can just open a different one for 'validation only'.

Revision history for this message
Clint Byrum (clint-fewbar) wrote :
Download full text (3.5 KiB)

It is a bug, but it isn't really all that important.

Excerpts from Amit Ugol's message of 2014-02-11 05:38:05 UTC:
> I opened this bug thinking that empty templates should not be validated as they create 'bad' stacks but then I saw the validation thing (as posted) and added that to the description as well. I know empty templates are YAML valid but IMO that does not mean that they are 'heat valid' as in heat will not be able to do anything with them, rendering them useless.
> If needs be I can just open a different one for 'validation only'.
>
> --
> You received this bug notification because you are subscribed to heat.
> https://bugs.launchpad.net/bugs/1278090
>
> Title:
> heat validates successfully empty template files
>
> Status in Orchestration API (Heat):
> Triaged
>
> Bug description:
> From the documentation in http://docs.openstack.org/user-guide/content
> /heat-stack-create.html:
>
> "
> You can also use the stack-create command to validate a template file without creating a stack from it.
> To do so, run the following command:
> $ heat stack-create mystack --template-file=/PATH_TO_HEAT_TEMPLATES/WordPress_Single_Instance.template
> "
>
> However trying to validate empty files or even null, will return a
> success:
>
>
> # heat stack-create test234 --template-file=/dev/null
> +--------------------------------------+------------+-----------------+----------------------+
> | id | stack_name | stack_status | creation_time |
> +--------------------------------------+------------+-----------------+----------------------+
> | f9e37e85-9c4b-4422-943c-a593c75d677f | test123 | CREATE_COMPLETE | 2014-02-09T13:38:42Z |
>
> # tail /var/log/heat/engine.log
> 2014-02-09 15:54:26.364 1778 INFO heat.engine.service [req-f9e37e85-9c4b-4422-943c-a593c75d677f ***** *****] template is {u'Parameters': {}, u'Outputs': {}, u'HeatTemplateFormatVersion': u'2012-12-12', u'Mappings': {}, u'Resources': {}}
>
>
> # mysql
> MariaDB [(none)]> use heat
> Reading table information for completion of table and column names
> You can turn off this feature to get a quicker startup with -A
>
> Database changed
> MariaDB [heat]> select * from stack where name='test123'\G;
> *************************** 1. row ***************************
> id: f9e37e85-9c4b-4422-943c-a593c75d677f
> created_at: 2014-02-09 13:38:42
> updated_at: 2014-02-09 13:38:42
> name: test123
> raw_template_id: 160
> user_creds_id: 160
> username: admin
> owner_id: NULL
> status: COMPLETE
> status_reason: Stack create completed successfully
> parameters: {"parameters": {}, "resource_registry": {"resources": {}}}
> timeout: 60
> tenant: 0e8b6030e87f49be8ae68fc37649a986
> disable_rollback: 1
> action: CREATE
> deleted_at: NULL
> 1 row in set (0.00 sec)
>
>
> Other info:
> # cat /etc/redhat-release
> Fedora release 20 (Heisenbug)
>
> # uname -a
> Linux ***domain*** 3.12.9-301.fc20.x86_64 #1 SMP Wed Jan 29 15:56:22 UTC 2014 x86_64 x86_64...

Read more...

Revision history for this message
Steven Hardy (shardy) wrote :

I see two issues:

1. heat template-validate fails to validate an empty template, but stack-create accepts it

2. The documentation is obviously wrong, you can't use stack-create to validate a template file without creating a stack from it, that's what template-validate is for. It's just a byproduct of failure if it returns useful info on validation failure.

Revision history for this message
Steven Hardy (shardy) wrote :

To clarify, I don't see any reason why we have to reject an empty stack, although it's obviously not the most useful thing to create. We use it in several places in tempest for example, just to exercise the API surface.

Changed in heat:
assignee: nobody → Sergey Kraynev (skraynev)
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/86623

Changed in heat:
status: Triaged → In Progress
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix merged to heat (master)

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

commit d102b1ee1c10d2a202fbdc7d18a2e931d8d09527
Author: Sergey Kraynev <email address hidden>
Date: Thu Apr 10 10:16:00 2014 -0400

    Make template validation uniform

    There were two different behaviours during template validation and creation
    stack (with template validation). In first case error was raised if
    template did not have any resources. However user could create stack
    without error using this such kind of template.
    This patch make behaviour equal for both variant and gives ability to
    create and successfully validate stack with template which does not have
    resources.

    Change-Id: I4dc30ccdc45e0fa7ff678b434106e056dba5f3b4
    Closes-Bug: #1278090

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