wrong quota_usages updated when admin deletes instance of common user

Bug #1078668 reported by Rongze Zhu
62
This bug affects 11 people
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
High
Guangyu Suo
OpenStack Compute (nova)
Fix Released
High
Guangyu Suo

Bug Description

When admin with admin project delete a instance of common user, QUOTA will update the admin project quota_usages, but I except QUOTA to update the quota_usages common user project. Below is my tests in devstack.

"the demo project _id is f293f8518b67465bb47af717c075e619.
"the admin project_id is 69d65864ae8242b580649252cacedaa3.

$ source openrc demo demo
$ nova boot --flavor=1 --image=89a0484b-a539-4c7b-b549-36c3c56fdcff test1
"the instance of demo project is e74c9b03-07d4-4988-96eb-ab7bc75411b1.

$ source openrc admin admin
$ nova boot --flavor=1 --image=89a0484b-a539-4c7b-b549-36c3c56fdcff test2
"the instance of admin project is 627f8491-9425-4364-aa1b-ec02a42f946b.

$ nova list --all-tenants=1
+--------------------------------------+-------+--------+------------------+
| ID | Name | Status | Networks |
+--------------------------------------+-------+--------+------------------+
| e74c9b03-07d4-4988-96eb-ab7bc75411b1 | test1 | ACTIVE | private=10.0.0.2 |
| 627f8491-9425-4364-aa1b-ec02a42f946b | test2 | ACTIVE | private=10.0.0.3 |
+--------------------------------------+-------+--------+------------------+

$ source openrc admin admin
$ nova delete e74c9b03-07d4-4988-96eb-ab7bc75411b1
$ nova list --all-tenants=1
+--------------------------------------+-------+--------+------------------+
| ID | Name | Status | Networks |
+--------------------------------------+-------+--------+------------------+
| 627f8491-9425-4364-aa1b-ec02a42f946b | test2 | ACTIVE | private=10.0.0.3 |
+--------------------------------------+-------+--------+------------------+

mysql> select * from quota_usages;
+---------------------+---------------------+------------+---------+----+----------------------------------+-----------+--------+----------+---------------+
| created_at | updated_at | deleted_at | deleted | id | project_id | resource | in_use | reserved | until_refresh |
+---------------------+---------------------+------------+---------+----+----------------------------------+-----------+--------+----------+---------------+
| 2012-11-08 10:58:51 | 2012-11-14 11:08:01 | NULL | 0 | 1 | f293f8518b67465bb47af717c075e619 | instances | 1 | 0 | NULL |
| 2012-11-08 10:58:51 | 2012-11-14 11:08:01 | NULL | 0 | 2 | f293f8518b67465bb47af717c075e619 | ram | 512 | 0 | NULL |
| 2012-11-08 10:58:51 | 2012-11-14 11:08:01 | NULL | 0 | 3 | f293f8518b67465bb47af717c075e619 | cores | 1 | 0 | NULL |
| 2012-11-13 16:56:47 | 2012-11-14 11:09:45 | NULL | 0 | 4 | 69d65864ae8242b580649252cacedaa3 | instances | 0 | 0 | NULL |
| 2012-11-13 16:56:47 | 2012-11-14 11:09:45 | NULL | 0 | 5 | 69d65864ae8242b580649252cacedaa3 | ram | 0 | 0 | NULL |
| 2012-11-13 16:56:47 | 2012-11-14 11:09:45 | NULL | 0 | 6 | 69d65864ae8242b580649252cacedaa3 | cores | 0 | 0 | NULL |
+---------------------+---------------------+------------+---------+----+----------------------------------+-----------+--------+----------+---------------+
6 rows in set (0.00 sec)

summary: - admin delete a instance of common user
+ wrong quota_usages updated when admin deletes instance of common user
Rongze Zhu (zrzhit)
Changed in nova:
assignee: nobody → Rongze Zhu (zrzhit)
Changed in nova:
status: New → Triaged
importance: Undecided → High
tags: added: folsom-backport-potential
Guangyu Suo (yugsuo)
Changed in nova:
assignee: Rongze Zhu (zrzhit) → yugsuo (yugsuo)
Revision history for this message
John Griffith (john-griffith) wrote :

Hi Yugsuo,
It looks like we have the same issue in Cinder with the volume count quotas, once you have a fix for Nova, would you mind having a look at implementing the same fix on the Cinder side?

Thanks,
John

Changed in cinder:
assignee: nobody → yugsuo (yugsuo)
importance: Undecided → High
status: New → Triaged
Revision history for this message
Guangyu Suo (yugsuo) wrote :

Ok, I will fix this bug as soon as possible !

Guangyu Suo (yugsuo)
Changed in nova:
status: Triaged → In Progress
Changed in cinder:
status: Triaged → In Progress
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/18640

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/18640
Committed: http://github.com/openstack/nova/commit/7974ad3247dc4264c1834c402cf4d30f10137890
Submitter: Jenkins
Branch: master

commit 7974ad3247dc4264c1834c402cf4d30f10137890
Author: yugsuo <email address hidden>
Date: Mon Jan 7 12:15:06 2013 +0800

    Fix quota updating when admin deletes common user's instance

    Add 'project_id=None' optional argument in QUOTAS related methods.

    There are two problems when admin deletes instances of common user
    before fixing this bug:
    Firstly, It will get tenant quotas using context.project_id which
    results in getting admin's quotas not common user's.
    Secondly, It will also get wrong quota usages using context.project_id
    when updating common user's quota_usages.

    So we could pass into QUOTAS related methods an optional argument to
    specify the tenant ID to be affected. And if it's not set, then we
    default to drawing the tenant ID from the context.

    Fixes: bug 1078668
    Change-Id: I59bc240d6547122d803a3ed3e1eeef26fc78f4f0

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → grizzly-3
status: Fix Committed → Fix Released
Guangyu Suo (yugsuo)
Changed in cinder:
assignee: Yug Suo (yugsuo) → nobody
Guangyu Suo (yugsuo)
Changed in cinder:
assignee: nobody → Yug Suo (yugsuo)
Revision history for this message
Guangyu Suo (yugsuo) wrote :
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/24045

Revision history for this message
Abel Lopez (al592b) wrote :

Can we please get this fixed in Folsom as well?

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/24045
Committed: http://github.com/openstack/cinder/commit/576c9b0880c32bfc8053550b8f25a76df98c60e4
Submitter: Jenkins
Branch: master

commit 576c9b0880c32bfc8053550b8f25a76df98c60e4
Author: Yug Suo <email address hidden>
Date: Mon Mar 11 16:30:07 2013 +0800

    Fix quota updating when admin deletes common user's volume

    Add 'project_id=None' optional argument in QUOTAS related methods.

    There are two problems when admin deletes volumes of common user
    before fixing this bug:
    Firstly, It will get tenant quotas using context.project_id which
    results in getting admin's quotas not common user's.
    Secondly, It will also get wrong quota usages using context.project_id
    when updating common user's quota_usages.

    So we could pass into QUOTAS related methods an optional argument to
    specify the tenant ID to be affected. And if it's not set, then we
    default to drawing the tenant ID from the context.

    Fixes: bug 1078668
    Change-Id: Ie250da84726d1c5c3280430038184000dfd1e9e2

Changed in cinder:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (milestone-proposed)

Fix proposed to branch: milestone-proposed
Review: https://review.openstack.org/25490

Changed in cinder:
milestone: none → grizzly-rc3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (milestone-proposed)

Reviewed: https://review.openstack.org/25490
Committed: http://github.com/openstack/cinder/commit/85b7453f68f76dcd6edd7043026e7a6676eadf23
Submitter: Jenkins
Branch: milestone-proposed

commit 85b7453f68f76dcd6edd7043026e7a6676eadf23
Author: Yug Suo <email address hidden>
Date: Mon Mar 11 16:30:07 2013 +0800

    Fix quota updating when admin deletes common user's volume

    Add 'project_id=None' optional argument in QUOTAS related methods.

    There are two problems when admin deletes volumes of common user
    before fixing this bug:
    Firstly, It will get tenant quotas using context.project_id which
    results in getting admin's quotas not common user's.
    Secondly, It will also get wrong quota usages using context.project_id
    when updating common user's quota_usages.

    So we could pass into QUOTAS related methods an optional argument to
    specify the tenant ID to be affected. And if it's not set, then we
    default to drawing the tenant ID from the context.

    Fixes: bug 1078668
    Change-Id: Ie250da84726d1c5c3280430038184000dfd1e9e2
    (cherry picked from commit 576c9b0880c32bfc8053550b8f25a76df98c60e4)

Changed in cinder:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: grizzly-3 → 2013.1
Thierry Carrez (ttx)
Changed in cinder:
milestone: grizzly-rc3 → 2013.1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (stable/folsom)

Fix proposed to branch: stable/folsom
Review: https://review.openstack.org/26269

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.