retype can result in negative values in quota_usages

Bug #1505307 reported by Ollie Leahy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Ollie Leahy

Bug Description

On a devstack installation with two lvm volume types created, retyping from one volume type to another can result in negative vales in the 'reserved' column in the quota_usages table.

To make this happen you need to pass different, probably admin, username and password on the command line.

ubuntu@trusty-devstack:/opt/stack/cinder$ mysql -uroot -ppassword cinder -e "select id,resource,reserved from quota_usages where project_id='f1a9a9b1cff94a37ab879679fa5b4c10';"
+----+-----------------------+----------+
| id | resource | reserved |
+----+-----------------------+----------+
| 1 | gigabytes | 0 |
| 2 | gigabytes_lvmdriver-1 | 0 |
| 3 | volumes_lvmdriver-1 | 0 |
| 4 | volumes | 0 |
| 5 | gigabytes_LUKS | 0 |
| 6 | volumes_LUKS | 0 |
| 7 | gigabytes_lvm2 | 0 |
| 8 | volumes_lvm2 | 0 |
+----+-----------------------+----------+

Retype a volume belonging to 'demo' but using 'admin' creds:

ubuntu@trusty-devstack:~/devstack$ cinder --os-username admin --os-tenant-name admin retype --migration-policy on-demand b60038b1-ca10-4d96-8b02-d82213ba419b lvmdriver-1

Now demo has negative values:

ubuntu@trusty-devstack:/opt/stack/cinder$ mysql -uroot -ppassword cinder -e "select id,resource,reserved from quota_usages where project_id='f1a9a9b1cff94a37ab879679fa5b4c10';"
+----+-----------------------+----------+
| id | resource | reserved |
+----+-----------------------+----------+
| 1 | gigabytes | -1 |
| 2 | gigabytes_lvmdriver-1 | -1 |
| 3 | volumes_lvmdriver-1 | -1 |
| 4 | volumes | -1 |
| 5 | gigabytes_LUKS | 0 |
| 6 | volumes_LUKS | 0 |
| 7 | gigabytes_lvm2 | 0 |
| 8 | volumes_lvm2 | 0 |
+----+-----------------------+----------+

and the admin user is left with an incorrect positive value for the same field:

ubuntu@trusty-devstack:/opt/stack/cinder$ mysql -uroot -ppassword cinder -e "select id,resource,reserved from quota_usages where project_id='57d75a9095ae4ad99722df9115fb2440';"
+----+-----------------------+----------+
| id | resource | reserved |
+----+-----------------------+----------+
| 9 | gigabytes | 1 |
| 10 | gigabytes_lvmdriver-1 | 1 |
| 11 | volumes_lvmdriver-1 | 1 |
| 12 | volumes | 1 |
+----+-----------------------+----------+

The side effect of this bug is that demo can now create one more volume than is specified b their volume quota. Retyping another volume in this way will allow them to create two extra volumes.

Tags: quota retype
Jay Bryant (jsbryant)
tags: added: quota retype
Changed in cinder:
assignee: nobody → Deepti Ramakrishna (dramakri)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

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

Changed in cinder:
assignee: Deepti Ramakrishna (dramakri) → Ollie Leahy (oliver-leahy-l)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

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

commit ceb65b6f868284a6738b5202ea44ac91198d9f1f
Author: Ollie Leahy <email address hidden>
Date: Thu Oct 15 15:20:28 2015 +0000

    Use project id from volume when retyping volumes

    Use the project_id from the volume being retyped to reserve quota in
    get_volume_type_reservation(). Previously the project_id from the
    context was used, which could cause reservations to be made and never
    cleared.

    Change-Id: I25f7c00961e259102cdaea6ea9394d04ded96b92
    Closes-Bug: #1505307

Changed in cinder:
status: In Progress → Fix Committed
Revision history for this message
Thierry Carrez (ttx) wrote : Fix included in openstack/cinder 8.0.0.0b1

This issue was fixed in the openstack/cinder 8.0.0.0b1 development milestone.

Thierry Carrez (ttx)
Changed in cinder:
status: Fix Committed → Fix Released
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.