wrong input of number parameter will result in abnormal behavior of heat

Bug #1321549 reported by xiejunan
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Angus Salkeld

Bug Description

when i assign a wrong value to a number_typed parameter , heat will work not correctly.

heat stack-create mystack -f para_number_01.yaml -P"para_number=aaaa"

error message like this: ERROR, can not covert string to float "aaaa", this is ok. but it when cr-create the stack, it looks like the stack

has been created sucessfully. when i list stacks using stack-list command, the client will throw the same message and no stack will be listed.

Revision history for this message
Thomas Herve (therve) wrote :

I can't reproduce it. It does fail with an error, and the stack is not created.

Changed in heat:
status: New → Incomplete
importance: Undecided → Medium
milestone: none → juno-1
Revision history for this message
xiejunan (xiejunan) wrote :

i re-cloned the code today. commands and corresponding messages just like:
heat stack-create mystack -f para_number.yaml -P"para_number=aaaa"
=>ERROR cloud not convert string to float: aaaa
heat stack-list
=>ERROR: cloud not convert string to float: aaaa
heat stack-create mystack -f para_number.yaml -P"para_number=80"
=>ERROR: the Stack(mystack) already exists.
heat stack-delete mystack
=>ERROR: cloud not convert string to float: aaaa
heat stack-create mystack -f para_number.yaml -P"para_number=8080"
=>create mystack sucessfully.

Revision history for this message
Sergey Kraynev (skraynev) wrote :

I can not reproduce this problem too. Could you say what version of heat do you use?

Changed in heat:
assignee: nobody → Thomas Spatzier (thomas-spatzier)
Revision history for this message
xiejunan (xiejunan) wrote :

my heat version: 0.2.9.13

Revision history for this message
Haiyang DING (dinghaiyang) wrote :

I can reproduce this one. When the input parameter does not satisfy the input constraint (using same command with xiejunan), it returns with:

ERROR: cloud not convert string to float: aaaa

which is fine.

However, when I use "heat stack-list" it says again:

ERROR: cloud not convert string to float: aaaa

which is not OK.

Further, when I try to create a new stack called "Test" (this choice is reasonable since the last "mystack" creation is supposed to be a failure thus does not exist), it returns with:

ERROR: The stack (mystack) already exists.

which is not OK.

There must be something wrong around here.

Now I have to ./unstack.sh + ./stack.sh to recover...

Revision history for this message
Sergey Kraynev (skraynev) wrote :

xiejunan: It's version of python-heatclient. My question was about heat project: it may be havana, icehouse, master and etc.

Haiyang DING: same question about release version of heat (not heatclient).

I use master and don't see such problem.

Revision history for this message
Sergey Kraynev (skraynev) wrote :

I have tried to reproduce it on icehouse release and have not got any error again.

@xiejunan, Haiyang DING: Could you provide more information about your deployments and how you got this error.
(May be heat-engine and heat-api logs be useful)

Revision history for this message
xiejunan (xiejunan) wrote :

i will check my environment as fast as possible.

Revision history for this message
xiejunan (xiejunan) wrote :

para_number_01.yaml :
heat_template_version: 2013-05-23
description: Simple template to deploy a single compute instance
parameters:
 para_number:
   type: number
   label: test number
   description: number description
   default: 80
   hidden: false

resources:
 my_instance1:
  type: OS::Nova::Server
  properties:
   key_name: heat_key
   image: cirros-0.3.1-x86_64-uec
   flavor: m1.tiny

outputs:
  ip_address:
    description: ip address
    value: { get_attr: [my_instance1,first_address]}
  para_number:
    description: para_number
    value: { get_param: para_number }
=================================

resources do not use this parameter.

Revision history for this message
xiejunan (xiejunan) wrote :

trace stack:
File "/opt/stack/heat/heat/openstack/common/rpc/amqp.py", line 462, in _process_data
   **args)
  File "/opt/stack/heat/heat/openstack/common/rpc/dispatcher.py", line 172, in dispatch
    result = getattr(proxyobj, method)(ctxt, **kwargs)
   File "/opt/stack/heat/heat/engine/service.py", line 62, in wrapped
    return func(self, ctx, *args, **kwargs)
  File "/opt/stack/heat/heat/engine/service.py", line 438, in list_stacks
 return list(format_stack_details(stacks))
 File "/opt/stack/heat/heat/engine/service.py", line 433, in format_stack_details
   yield api.format_stack(stack)
  File "/opt/stack/heat/heat/engine/api.py", line 91, in format_stack
    api.STACK_PARAMETERS: stack.parameters.map(str),
 File "/opt/stack/heat/heat/engine/parameters.py", line 434, in map
   for n, p in self.params.iteritems() if filter_func(p))
  File "/opt/stack/heat/heat/engine/parameters.py", line 434, in <genexpr>
 for n, p in self.params.iteritems() if filter_func(p))
  File "/opt/stack/heat/heat/engine/parameters.py", line 259, in __str__
   value = self.value()
  File "/opt/stack/heat/heat/engine/parameters.py", line 284, in value
  return float(self)
 File "/opt/stack/heat/heat/engine/parameters.py", line 275, in __float__
   return float(super(NumberParam, self).value())
ValueError: could not convert string to float: aaaa

Revision history for this message
Sergey Kraynev (skraynev) wrote :

@xiejunan: Thanks. Now I can reproduce it with provided template.

Changed in heat:
assignee: Thomas Spatzier (thomas-spatzier) → Sergey Kraynev (skraynev)
Revision history for this message
xiejunan (xiejunan) wrote :

i think i have found the reason:

heat/engine/parameters.py class NumberParam

 def _validate(self, val, context):
        self.schema.validate_value(self.name, val, context)
        #added by xiejunan : constraint checking is not enough, try to get value of number
        self.value()

Changed in heat:
assignee: Sergey Kraynev (skraynev) → xiejunan (xiejunan)
Revision history for this message
Sergey Kraynev (skraynev) wrote :

@xiejunan: If you sure, that it works, please upload a fix.

xiejunan (xiejunan)
Changed in heat:
status: Incomplete → 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/96390

Thierry Carrez (ttx)
Changed in heat:
milestone: juno-1 → juno-2
Revision history for this message
Ethan Lynn (ethanlynn) wrote :

Sorry I didn't notice this bug and open a new bug https://bugs.launchpad.net/heat/+bug/1329152
and upload a patch to fix this.

Revision history for this message
Ethan Lynn (ethanlynn) wrote :

My patch is also in review:
https://review.openstack.org/#/c/99561/

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

The proposed patch has negative feedback which has not been addressed in over a month. Bumping to J3.

Changed in heat:
milestone: juno-2 → juno-3
Revision history for this message
xiejunan (xiejunan) wrote :

Ethan Lyunn has fixed this bug. this bug can be abandoned.

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

I think there is a missing part to this bug:
stack-list should never fail on a validation error.

$ heat stack-list
'stacks'

heat-api log:

JSON response : {"explanation": "The server could not comply with the request since it is either malformed or otherwise incorrect.", "code": 400, "error": {"message": "The Parameter (image) was not defined in template.", "traceback": "Traceback (most recent call last):\n\n File \"/opt/stack/heat/heat/engine/service.py\", line 63, in wrapped\n return func(self, ctx, *args, **kwargs)\n\n File \"/opt/stack/heat/heat/engine/service.py\", line 458, in list_stacks\n return [api.format_stack(stack) for stack in stacks]\n\n File \"/opt/stack/heat/heat/engine/stack.py\", line 251, in load_all\n yield cls._from_db(context, stack, resolve_data=resolve_data)\n\n File \"/opt/stack/heat/heat/engine/stack.py\", line 268, in _from_db\n use_stored_context=use_stored_context)\n\n File \"/opt/stack/heat/heat/engine/stack.py\", line 113, in __init__\n context=self.context)\n\n File \"/opt/stack/heat/heat/engine/parameters.py\", line 437, in validate\n self._validate_user_parameters()\n\n File \"/opt/stack/heat/heat/engine/parameters.py\", line 480, in _validate_user_parameters\n raise exception.UnknownUserParameter(key=param)\n\nUnknownUserParameter: The Parameter (image) was not defined in template.\n", "type": "UnknownUserParameter"}, "title": "Bad Request"} from (pid=27501) to_json /opt/stack/heat/heat/common/serializers.py:43

stack-list should say
stack-X | unparsable

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/110536

Changed in heat:
assignee: xiejunan (xiejunan) → Angus Salkeld (asalkeld)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on heat (master)

Change abandoned by Angus Salkeld (<email address hidden>) on branch: master
Review: https://review.openstack.org/110536
Reason: there is an equivalent patch in already.

Revision history for this message
Angus Salkeld (asalkeld) wrote :
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: juno-3 → 2014.2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Angus Salkeld (<email address hidden>) on branch: master
Review: https://review.openstack.org/96390
Reason: adandoning old reviews, feel free to repost this if you want to get it merged.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.