mandatory fields are not enforced in launch stack

Bug #1303865 reported by Ami Jeain
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Invalid
Medium
Miguel Grinberg
OpenStack Heat
Fix Released
Medium
Sirushti Murugesan

Bug Description

- go to the Create Stack screen, enter the following valid Heat template:
heat_template_version: 2013-05-23
description: >
  A single stack with a keypair.

parameters:
  key_name:
    type: string
    default: heat_key3
  key_save:
    type: string
    default: false

resources:
  KeyPair:
    type: OS::Nova::KeyPair
    properties:
      name: { get_param: key_name }
      save_private_key: { get_param: key_save }

outputs:
  PublicKey:
    value: { get_attr: [KeyPair, public_key] }
  PrivateKey:
    value: { get_attr: [KeyPair, private_key] }

 - delete one of the fields value (key_name or/and key_save)
=> you will get a message saying "Error: Stack creation failed."

In horizon.log you will get:
2014-04-07 14:49:23,055 7116 DEBUG heatclient.common.http
HTTP/1.1 400 Bad Request
date: Mon, 07 Apr 2014 14:49:23 GMT
content-length: 301
content-type: application/json; charset=UTF-8

{"explanation": "The server could not comply with the request since it is either malformed or otherwise incorrect.", "code": 400, "error": {"message": "Property error : KeyPair: save_private_key \"\" is not a valid boolean", "traceback": null, "type": "StackValidationFailed"}, "title": "Bad Request"}

if any/all of the 2 fields is mandatory, this should be enforced, both with a message, and with an asterisk, right next to the field.

Revision history for this message
David Lyle (david-lyle) wrote :

What version are you using? On master, when following the prescribed steps I get a form validation error "An unknown problem occurred validating the template." This section of code was updated in i-3.

Changed in horizon:
status: New → Incomplete
Revision history for this message
Ami Jeain (ajeain) wrote :

# rpm -qa |grep horizon
python-django-horizon-2014.1-0.5.b3.el7.noarch

Revision history for this message
Ana Krivokapić (akrivoka) wrote :

I could reproduce this on current master.

Changed in horizon:
status: Incomplete → Triaged
importance: Undecided → Medium
Changed in horizon:
assignee: nobody → Cristian A Sanchez (cristian-a-sanchez)
Changed in horizon:
assignee: Cristian A Sanchez (cristian-a-sanchez) → nobody
Revision history for this message
Jeremy Moffitt (jeremy-moffitt) wrote :

Tried reproducing this and got the following error message:
ERROR: Template not in valid format: mapping values are not allowed in this context

I may be doing something wrong... I put the specified template text in the "Template Data" field after changing "Template Source" to "Direct Input". I left the environment source set to file but didn't select one. The error appeared when I clicked "Next"

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

@Jeremy Hard to say exactly why, I guess you removed something that made this template invalid.
@Ami, can you please paste here an exact before and after templates? Note that if the after template is invalid, Horizon will show the error message as it receives it from heat.

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

I was able to reproduce this bug. Here are the detailed steps I followed:

1. In the Horizon Stacks page, click "Launch Stack"
2. Set "Template Source" to "Direct Input"
3. Paste the Heat template exactly as shown above in the "Template Data" box.
4. Leave all the other fields with their defaults and click "Next"
5. In the next page give the stack a name, and enter the admin password.
6. Now there are two possible choices:
    6a. Clear field "key_name" (which is set to the default "heat_key3") and then click "Launch".
          In this case I get a "Stack creation started" green status message, but the stack quickly goes to an error state.
          If I open the stack the following error message is shown:
          Resource Create Failed: Badrequest: Keypair Data Is Invalid: Keypair Name Must Be Between 1 And 255 Characters Long (Http 400)
    6b. Clear the field "key_save" (which is set to the default "false") and then click "Launch"
          In this case I get an immediate error that reads "Error: ERROR: Property error : KeyPair: save_private_key "" is not a valid boolean", and the form stays up so I can go and make corrections.

While the 6a and 6b cases error in different ways, both are a result of sending parameters into Heat with a value of an empty string. Case 6b is interesting, because this parameter is of type string, yet it is used as a boolean. I think the 6a case is more representative of this bug, where Horizon submits the stack and Heat accepts it, but then shortly after it detects the empty value(s) and returns an error asynchronously.

The logic in the launch stack form makes any template parameters that don't have a default value required, but leaves those that have defaults with required set to False. Given that the default values for parameters are pre-filled in the form, it may seem better to make all parameter fields required. An alternative approach would be to leave the parameters with default as not required, but reset them to the default if they are submitted empty.

I'm happy to attempt a fix, but would like to have some opinions on which of the two solutions I presented above is preferred.

Changed in horizon:
assignee: nobody → Miguel Grinberg (miguelgrinberg)
Revision history for this message
Steve Baker (steve-stevebaker) wrote :

The empty name issue looks like a heat bug. The KeyPair resource needs better validation that the name is between 1 and 255 characters.

The save_private_key error seems reasonable though, an empty string is not a boolean.

Changed in heat:
status: New → Triaged
importance: Undecided → Medium
milestone: none → juno-3
Changed in heat:
assignee: nobody → Sirushti Murugesan (sirushtim)
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/118162

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

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

commit 805115d6ff57e742bc59761ec16fedc15d47e638
Author: Sirushti Murugesan <email address hidden>
Date: Mon Sep 1 18:47:51 2014 +0530

    Add length constraint to Nova Keypair's name property

    Sets min/max bounds of the Nova Keypair Resource's name
    property to 1 and 255 respectively.

    Change-Id: I48fb25eee465938fd7e48e105187d1646c8c64c0
    Closes-Bug: #1303865

Changed in heat:
status: In Progress → Fix Committed
Revision history for this message
Miguel Grinberg (miguelgrinberg) wrote :

With the heat fix in place Horizon reports template errors immediately and gives the user the chance to make a correction, so I don't think any action is required on the Horizon side.

Changed in horizon:
status: Triaged → Invalid
Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: juno-3 → 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.