nova flavor-create raises 500 error if large value passed to flavor properties

Bug #1577727 reported by Dinesh Bhor
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Dinesh Bhor

Bug Description

If large value is provided for properties other than name and ID then 500 error is raised.

All integral flavor properties are validated against db.MAX_INT(2147483647) for maximum limit and raised exception.InvalidInput for invalid input.
As exception.InvalidInput is not caught, it is returning 500 InternalServerError.

Expected result:
Instead of 500 InternalServerError it should return 400 HTTPBadRequest with message 'Invalid input received: ram must be <= 2147483647'.

Command:
nova flavor-create new_flavor 35 23478279183291369182 200 2

Output:
ERROR (ClientException): Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.
<class 'nova.exception.InvalidInput'> (HTTP 500) (Request-ID: req-35f422d1-7232-4dfa-ab8e-7de36d11dcaf)

n-api LOG:

2016-05-04 06:15:20.072 ERROR nova.api.openstack.extensions [req-35f422d1-7232-4dfa-ab8e-7de36d11dcaf admin admin] Unexpected exception in API method
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions Traceback (most recent call last):
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/api/openstack/extensions.py", line 478, in wrapped
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions return f(*args, **kwargs)
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/api/validation/__init__.py", line 73, in wrapper
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions return func(*args, **kwargs)
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/api/validation/__init__.py", line 73, in wrapper
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions return func(*args, **kwargs)
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/api/openstack/compute/flavor_manage.py", line 81, in _create
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions is_public=is_public)
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/compute/flavors.py", line 152, in create
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions db.MAX_INT)
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/utils.py", line 1030, in validate_integer
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions 'max_value': max_value})
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions InvalidInput: Invalid input received: ram must be <= 2147483647
2016-05-04 06:15:20.072 TRACE nova.api.openstack.extensions

Tags: api
Changed in nova:
assignee: nobody → Dinesh Bhor (dinesh-bhor)
Revision history for this message
Pushkar Umaranikar (pushkar-umaranikar) wrote :

Can you please reply with why you are using long value? Attributes of nova flavor-create command including uuid, amount of ram, vcpus etc. should be positive integers. From the command in the bug description, it seems like you are passing long value for ram. It expects an integer value. Hence, above is an expected error.
kindly refer, http://docs.openstack.org/admin-guide/cli_manage_flavors.html

Changed in nova:
status: New → Invalid
tags: added: api
summary: - nova flavor-create raises 500 error if long value passed to flavor
+ nova flavor-create raises 500 error if large value passed to flavor
properties
description: updated
Revision history for this message
Dinesh Bhor (dinesh-bhor) wrote :

Hi Pushkar,

Thank you for your comment. I have updated the bug description for better understanding.
Please let me know if you have any questions.

Changed in nova:
status: Invalid → New
Revision history for this message
Pushkar Umaranikar (pushkar-umaranikar) wrote :

Thank you for detailed description. I think a message saying invalid input in response to client can be a solution for this.

Changed in nova:
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

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

Reviewed: https://review.openstack.org/313234
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=9e0032362188d3b4c6ad21881a08275591461d03
Submitter: Jenkins
Branch: master

commit 9e0032362188d3b4c6ad21881a08275591461d03
Author: dineshbhor <email address hidden>
Date: Fri Apr 29 12:46:55 2016 +0000

    Return 400 HTTP error for invalid flavor attributes

    Currently create flavor API raises 500 error if you
    pass large value to ram, disk, vcpu, swap, ephemeral,
    rxtx_factor flavor properties. All integral flavor
    properties are validated against db.MAX_INT(2147483647)
    for maximum limit and raised exception.InvalidInput for
    invalid input.

    Added validation of maximum limit for flavor properties
    in schema. Kept the validation of flavor properties as it
    is in nova.compute.flavors as it is used by legacy flavor
    create. Moved the SQL_SP_FLOAT_MAX constant to nova.db.api
    so that it can be used in schema as well as in test files.

    APIImpact: Return 400 status code for invalid flavor
    properties.

    Closes-Bug: #1577727
    Change-Id: I4e50534d67ee90c585b6679644e06ee3569c8c97

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack/nova 14.0.0.0b1

This issue was fixed in the openstack/nova 14.0.0.0b1 development milestone.

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.