some md-* create and update API's returns 500 error if user passes name with more than 80 characters

Bug #1719252 reported by Dinesh Bhor on 2017-09-25
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Low
Dinesh Bhor

Bug Description

Following apis are returning 500 error if user passes name with more
than 80 characters:
* md-tag-create
* md-tag-update
* md-object-create
* md-object-update
* md-property-create
* md-property-update

This happens because there is a discrepancy in db column length and
glance-api length check in schema validation. In database the 'name'
field for these API's is defined as of maximum 80 characters and in
schema it is defined as of maximum 255 characters. So if user passes
name with more than 80 characters and less than 255 characters
database fails to store that value and shouts with following error
which leads to 500 error to API user:

(pymysql.err.DataError) (1406, u"Data too long for column 'name' at
row 1")

Steps to reproduce:

On current glance master:

commit a6fa8d9ce7b135ef9fa6d38aa7a8c1cffebf0baa
Merge: a1c8966 97158c3
Author: Jenkins <email address hidden>
Date: Wed Sep 20 17:17:20 2017 +0000

    Merge "Open Queens for data migrations"

command:
$ glance md-tag-update --name Ab22222222222222222222222222222222222
2222222222222222222222222222222222222222222222222222222222222222222
2222222 OS::Compute::vMware Ab2

500 Internal Server Error: The server has either erred or is incapable
of performing the requested operation. (HTTP 500)

g-api logs:

Sep 18 15:45:22 dbopenstack-VirtualBox <email address hidden>[9103]:
ERROR glance.api.v2.metadef_tags [None req-af8f8144-6724-46a5-9d57-5fc
37d40fb2d admin admin] (pymysql.err.DataError) (1406, u"Data too long
for column 'name' at row 1") [SQL: u'UPDATE metadef_tags SET updated_at
=%(updated_at)s, name=%(name)s WHERE metadef_tags.id = %(metadef_tags_id)s']
[parameters: {'metadef_tags_id': 4, 'name': u'Ab2222222222222222222222222222222222222222222222222222222222222222222
222222222222222222222222222222222222222222',
'updated_at': datetime.datetime(2017, 9, 18, 10, 15, 22, 367087)}]:
DBDataError: (pymysql.err.DataError) (1406, u"Data too long for column
 'name' at row 1") [SQL: u'UPDATE metadef_tags
SET updated_at=%(updated_at)s, name=%(name)s WHERE metadef_tags.id =
%(metadef_tags_id)s'] [parameters: {'metadef_tags_id': 4, 'name':
 u'Ab22222222222222222222222222222222222222222222222222222222222222222
22222222222222222222222222222222222222222222', 'updated_at':
datetime.datetime(2017, 9, 18, 10, 15, 22, 367087)}]
Sep 18 15:45:22 dbopenstack-VirtualBox <email address hidden>[9103]:
[pid: 9108|app: 0|req: 23/46] 127.0.0.1 () {40 vars in 659 bytes}
[Mon Sep 18 15:45:22 2017]
PUT /v2/metadefs/namespaces/OS::Compute::vMware/tags/Ab2 =>
generated 228 bytes in 72 msecs (HTTP/1.1 500) 4 headers in 184 bytes
(1 switches on core 0)

Changed in glance:
assignee: nobody → Dinesh Bhor (dinesh-bhor)

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

Changed in glance:
status: New → In Progress
Changed in glance:
importance: Undecided → Low

Reviewed: https://review.openstack.org/507433
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=2562da28c6171cc5372d3a695af00e22134a360b
Submitter: Jenkins
Branch: master

commit 2562da28c6171cc5372d3a695af00e22134a360b
Author: Dinesh Bhor <email address hidden>
Date: Tue Sep 19 18:35:56 2017 +0530

    Fix 500 if user passes name with more than 80 characters

    Following apis are returning 500 error if user passes name with more
    than 80 characters:
    * md-tag-create
    * md-tag-update
    * md-object-create
    * md-object-update
    * md-property-create
    * md-property-update

    This happens because there is a discrepancy in db column length and
    glance-api length check in schema validation. In database the 'name'
    field for these API's is defined as of maximum 80 characters and in
    schema it is defined as of maximum 255 characters. So if user passes
    name with more than 80 characters and less than 255 characters
    database fails to store that value and shouts with following error
    which leads to 500 error to API user:

    (pymysql.err.DataError) (1406, u"Data too long for column 'name' at
    row 1")

    Fixed this issue by changing the maximum allowed length for 'name'
    from 255 to 80 in schema validation.

    APIImpact
    DocImpact
    Closes-Bug: #1719252
    Change-Id: I4ae67457c3e4f5a6bfc3c1db2d305a9b7587395f

Changed in glance:
status: In Progress → Fix Released

This issue was fixed in the openstack/glance 16.0.0.0b1 development milestone.

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

Other bug subscribers