[heat] certain template errors display a long stack trace in the red error popup

Bug #1393831 reported by Miguel Grinberg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Undecided
Miguel Grinberg

Bug Description

I have found that certain types of template errors are not caught in the first validation pass, and instead fail in the second phase, when all the parameters are submitted.

For example, adding an invalid property to an output does this. Here is an example (only showing the "outputs" section):

outputs:
  mysql_instance_name:
    description: Name of the MySQL instance
    value: { get_attr: [mysql_instance, name] }
  mysql_instance_ip:
    description: The IP address of the MySQL instance
    value: { get_attr: [mysql_instance, first_address] }
  mysql_password:
    description: The MySQL root password
    value: { get_attr: [mysql_password, value] }
    hidden: true

The "hidden" parameter is invalid for an output, but the initial template validation does not find an error (likely a Heat problem). When the template is finally submitted a stack trace appears in the red popup error (see attached screenshot).

Changed in horizon:
assignee: nobody → Miguel Grinberg (miguelgrinberg)
Revision history for this message
Miguel Grinberg (miguelgrinberg) wrote :
Revision history for this message
Miguel Grinberg (miguelgrinberg) wrote :

Moved bug to heat project, this message comes from heat-engine, same happens when using command line client:

$ heat stack-create test -f bug.yaml
ERROR: u'u\'"hidden" is not a valid keyword inside an output definition\'\nTraceback (most recent call last):\n\n File "/usr/local/lib/python2.7/dist-packages/oslo/messaging/rpc/dispatcher.py", line 134, in _dispatch_and_reply\n incoming.message))\n\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\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\n File "/usr/local/lib/python2.7/dist-packages/osprofiler/profiler.py", line 105, in wrapper\n return f(*args, **kwargs)\n\n File "/opt/stack/heat/heat/engine/service.py", line 72, in wrapped\n return func(self, ctx, *args, **kwargs)\n\n File "/opt/stack/heat/heat/engine/service.py", line 678, in create_stack\n user_creds_id)\n\n File "/opt/stack/heat/heat/engine/service.py", line 593, in _parse_template_and_validate_stack\n **common_params)\n\n File "/opt/stack/heat/heat/engine/stack.py", line 137, in __init__\n self.outputs = self.resolve_static_data(self.t[self.t.OUTPUTS])\n\n File "/opt/stack/heat/heat/engine/hot/template.py", line 108, in __getitem__\n return self._translate_outputs(the_section)\n\n File "/opt/stack/heat/heat/engine/hot/template.py", line 172, in _translate_outputs\n _(\'"%s" is not a valid \'\n\n File "/opt/stack/heat/heat/engine/hot/template.py", line 118, in _translate\n raise KeyError(err_msg % value)\n\nKeyError: u\'"hidden" is not a valid keyword inside an output definition\'\n'

affects: horizon → heat
Revision history for this message
Miguel Grinberg (miguelgrinberg) wrote :

Here is a simple template that reproduces this issue:

heat_template_version: 2013-05-23

resources:
  my_instance:
    type: OS::Nova::Server
    properties:
      image: cirros-0.3.2-x86_64-uec
      flavor: m1.nano

outputs:
  instance_ip:
    description: IP address of the instance
    value: { get_attr: [my_instance, first_address] }
    hidden: true

Revision history for this message
Miguel Grinberg (miguelgrinberg) wrote :

This problem occurs when an exception is raised in heat-engine. The exception is serialized and transmitted over to heat-api. The deserializing of the exception is done by oslo.messaging, and this is where the exception's message is assembled using the message of the original exception plus the stack trace.

Relevant code: https://github.com/openstack/oslo.messaging/blame/0aa3312b46358de6c14fdadaa990ce2e90daf086/oslo/messaging/_drivers/common.py#L226

Need to figure out how this is handled in other modules.

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/137290

Changed in heat:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

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

commit af48daa6931839e1f860664f829cad631509f643
Author: Miguel Grinberg <email address hidden>
Date: Wed Nov 26 06:42:51 2014 +0000

    Consider invalid keywords a template validation error

    This commit changes the exception type raised when an invalid
    keyword is found in the resources and outputs sections of hot
    templates from a KeyError to a StackValidationFailed. The
    latter is better suited to be sent to heat-api to return to
    clients, as oslo.messaging deserializes it to a more compact
    exception that does not include the stack trace in the message
    string.

    Change-Id: I7c2da96fa07503b947c6c2c4a5f8ed3231dec9db
    Closes-Bug: 1393831

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