quota-class-update api return 500 error if value is above mysql INT type

Bug #1463379 reported by Abhijeet Malawade
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Pranali Deore

Bug Description

Cinder quota-class-update api return 500 error if update value is greater than mysql INT type.

steps to reproduce:

$ cinder quota-class-update --snapshots 2147483648 default
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)

OR

curl -g -i -X PUT http://10.69.4.179:8776/v2/db5fdc40c1534a8aa0c9a65e10513f83/os-quota-class-sets/default -H "User-Agent: python-cinderclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}850d5da510c4752d46db793bfd0fd19c320ba73d" -d '{"quota_class_set": {"class_name": "default", "snapshots": 2147483648}}

c-api error log:

2015-06-09 04:37:18.332 INFO cinder.api.openstack.wsgi [req-53ebce6c-6fba-4cde-9f95-4e201cb973bb 5c7cc769f1bd4f00825b7e69f6b71425 89c25c1a1be74f04bf9c19ec952846f3] PUT http://10.69.4.173:8776/v2/89c25c1a1be74f04bf9c19ec952846f3/os-quota-class-sets/default
2015-06-09 04:37:18.348 ERROR oslo_db.sqlalchemy.exc_filters [req-2fb61b13-1350-44e1-a231-e0981e10aa12 None None] DBAPIError exception wrapped from (DataError) (1264, "Out of range value for column 'hard_limit' at row 1") 'UPDATE quota_classes SET updated_at=%s, hard_limit=%s WHERE quota_classes.id = %s' (datetime.datetime(2015, 6, 9, 11, 37, 18, 347674), 2147483648, 2L)
2015-06-09 04:37:18.348 TRACE oslo_db.sqlalchemy.exc_filters Traceback (most recent call last):
2015-06-09 04:37:18.348 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 951, in _execute_context
2015-06-09 04:37:18.348 TRACE oslo_db.sqlalchemy.exc_filters context)
2015-06-09 04:37:18.348 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 436, in do_execute
2015-06-09 04:37:18.348 TRACE oslo_db.sqlalchemy.exc_filters cursor.execute(statement, parameters)
2015-06-09 04:37:18.348 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
2015-06-09 04:37:18.348 TRACE oslo_db.sqlalchemy.exc_filters self.errorhandler(self, exc, value)
2015-06-09 04:37:18.348 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
2015-06-09 04:37:18.348 TRACE oslo_db.sqlalchemy.exc_filters raise errorclass, errorvalue
2015-06-09 04:37:18.348 TRACE oslo_db.sqlalchemy.exc_filters DataError: (1264, "Out of range value for column 'hard_limit' at row 1")
2015-06-09 04:37:18.348 TRACE oslo_db.sqlalchemy.exc_filters
2015-06-09 04:37:18.350 ERROR cinder.api.middleware.fault [req-2fb61b13-1350-44e1-a231-e0981e10aa12 None None] Caught error: (DataError) (1264, "Out of range value for column 'hard_limit' at row 1") 'UPDATE quota_classes SET updated_at=%s, hard_limit=%s WHERE quota_classes.id = %s' (datetime.datetime(2015, 6, 9, 11, 37, 18, 347674), 2147483648, 2L)
2015-06-09 04:37:18.351 INFO cinder.api.middleware.fault [req-2fb61b13-1350-44e1-a231-e0981e10aa12 None None] http://10.69.4.173:8776/v2/89c25c1a1be74f04bf9c19ec952846f3/os-quota-class-sets/default returned with HTTP 500

Changed in cinder:
assignee: nobody → Abhijeet Malawade (abhijeet-malawade)
Changed in cinder:
assignee: Abhijeet Malawade (abhijeet-malawade) → Pranali Deore (pranali-deore)
status: New → In Progress
Changed in cinder:
assignee: Pranali Deore (pranali-deore) → Abhijeet Malawade (abhijeet-malawade)
Changed in cinder:
assignee: Abhijeet Malawade (abhijeet-malawade) → Pranali Deore (pranali-deore)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/194968
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=cf67960607844ef3426cae4d6e2ab96f16187b99
Submitter: Jenkins
Branch: master

commit cf67960607844ef3426cae4d6e2ab96f16187b99
Author: PranaliDeore <email address hidden>
Date: Wed Jun 17 04:49:24 2015 -0700

    Validate string, integer limit for input parameter

    1. Below apis will return 500 error code on passing name or description
       parameters with more than 255 characters:
       a. consisgroup-create
       b. consisgroup-update
       c. cgsnapshot-create
       d. quota-class-update
       e. quota-update
       f. qos-create
       g. volume-manage
       h. volume-transfer

    2. Below apis will return 500 error code on passing 'hard_limit' value
       greater than mysql INT type:
       a. quota-class-update
       b. quota-update
       c. encryption-type-create

    3. Below apis accept name as string with whitespaces:
       a. consisgroup-create
       b. cgsnapshot-create
       c. qos-create
       d. volume-transfer

    4. Type-key api will return 500 error code on passing key or value with
       more than 255 characters.

    Added new method
    1. validate_name_and_description() in
       cinder.api.openstack.wsgi.Controller to validate length of name and
       description and returned 400 if it exceeds the limit and removing
       leading or trailing whitespaces and string containing only
       whitespaces.
    2. validate_string_length() in cinder.api.openstack.wsgi.Controller to
       validate length of string and returned 400 if it exceeds the limit.
    3. validate_integer() method in cinder.utils to validate integer
       limit and returned 400 if limit exceeds.

    APIImpact
    1. For all above apis 400 response will be returned.
    2. Earlier it was possible to pass only whitespaces or leading-trailing
       spaces to 'name' parameters and 'key' while updating key-value in
       type-key api.
       Now it will raise 400 error if only whitespaces are passed and will
       remove leading-trailing spaces if present in other cases.

    Closes-Bug: 1466351
    Closes-Bug: 1463379
    Closes-Bug: 1465967
    Change-Id: I0c0029d61ba2b293b579d1afffec0bdf062b22a8

Changed in cinder:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in cinder:
milestone: none → liberty-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in cinder:
milestone: liberty-3 → 7.0.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.