Quota usage data wrong after instance resized by admin

Bug #1271541 reported by Liyingjun
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Liyingjun
Icehouse
Fix Released
Undecided
Unassigned

Bug Description

If the instance of a normal user is resized by admin, the user_id for quota usage will be changed to admin.

Reproduce:
We have two user 'admin' and 'test1' which is a normal user.
1. Create an instance by 'test1', the quota_usage table should be like:
mysql> select * from quota_usages;
+---------------------+---------------------+------------+----+----------------------------------+-----------+--------+----------+---------------+---------+----------------------------------+
| created_at | updated_at | deleted_at | id | project_id | resource | in_use | reserved | until_refresh | deleted | user_id |
+---------------------+---------------------+------------+----+----------------------------------+-----------+--------+----------+---------------+---------+----------------------------------+
| 2014-01-13 08:31:28 | 2014-01-13 08:31:28 | NULL | 7 | 6a47816024ef4860b1a218510a1658a9 | instances | 1 | 0 | NULL | 0 | ea75fd9954244be9b92c2aec99305f63 |
| 2014-01-13 08:31:28 | 2014-01-13 08:31:28 | NULL | 8 | 6a47816024ef4860b1a218510a1658a9 | ram | 512 | 0 | NULL | 0 | ea75fd9954244be9b92c2aec99305f63 |
| 2014-01-13 08:31:28 | 2014-01-13 08:31:28 | NULL | 9 | 6a47816024ef4860b1a218510a1658a9 | cores | 1 | 0 | NULL | 0 | ea75fd9954244be9b92c2aec99305f63 |
+---------------------+---------------------+------------+----+----------------------------------+-----------+--------+----------+---------------+---------+----------------------------------+

2. Resize the instance by admin:
# nova list --all-tenants
+--------------------------------------+------+--------+------------+-------------+-----------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+-----------------+
| a05f62b8-3f14-473c-9d64-b950b4dbfc9e | test | ACTIVE | None | Running | test=10.10.10.2 |
+--------------------------------------+------+--------+------------+-------------+-----------------+

# nova flavor-list
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1 | m1.tiny | 512 | 1 | 0 | | 1 | 1.0 | True |
| 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True |
| 2ee75e0f-37e1-4561-a5e2-43b8fd677547 | m2.tiny | 512 | 0 | 0 | | 2 | 1.0 | True |
| 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True |
| 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True |
| 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True |
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+

# nova resize a05f62b8-3f14-473c-9d64-b950b4dbfc9e 2ee75e0f-37e1-4561-a5e2-43b8fd677547

quota_usage table would create new records with the user_id for the admin.
mysql> select * from quota_usages;
+---------------------+---------------------+------------+----+----------------------------------+-----------+--------+----------+---------------+---------+----------------------------------+
| created_at | updated_at | deleted_at | id | project_id | resource | in_use | reserved | until_refresh | deleted | user_id |
+---------------------+---------------------+------------+----+----------------------------------+-----------+--------+----------+---------------+---------+----------------------------------+
| 2014-01-13 08:31:28 | 2014-01-13 08:31:28 | NULL | 7 | 6a47816024ef4860b1a218510a1658a9 | instances | 1 | 0 | NULL | 0 | ea75fd9954244be9b92c2aec99305f63 |
| 2014-01-13 08:31:28 | 2014-01-13 08:31:28 | NULL | 8 | 6a47816024ef4860b1a218510a1658a9 | ram | 512 | 0 | NULL | 0 | ea75fd9954244be9b92c2aec99305f63 |
| 2014-01-13 08:31:28 | 2014-01-13 08:31:28 | NULL | 9 | 6a47816024ef4860b1a218510a1658a9 | cores | 1 | 0 | NULL | 0 | ea75fd9954244be9b92c2aec99305f63 |
| 2014-01-13 08:39:28 | 2014-01-13 08:39:28 | NULL | 10 | 6a47816024ef4860b1a218510a1658a9 | cores | 0 | 1 | NULL | 0 | ad99c3d4311b4940b083b52fbf73789c |
| 2014-01-13 08:39:28 | 2014-01-13 08:39:28 | NULL | 11 | 6a47816024ef4860b1a218510a1658a9 | instances | 0 | 0 | NULL | 0 | ad99c3d4311b4940b083b52fbf73789c |
| 2014-01-13 08:39:28 | 2014-01-13 08:39:28 | NULL | 12 | 6a47816024ef4860b1a218510a1658a9 | ram | 0 | 0 | NULL | 0 | ad99c3d4311b4940b083b52fbf73789c |
+---------------------+---------------------+------------+----+----------------------------------+-----------+--------+----------+---------------+---------+----------------------------------+

Liyingjun (liyingjun)
Changed in nova:
assignee: nobody → Liyingjun (liyingjun)
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/68391

Changed in nova:
status: New → In Progress
Andrew Laski (alaski)
tags: added: icehouse-rc-potential
Changed in nova:
importance: Undecided → Medium
importance: Medium → High
Thierry Carrez (ttx)
tags: added: icehouse-backport-potential
removed: icehouse-rc-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/82376
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=0a717d7085bd2bca7e5408a5c20e8ae7cd055756
Submitter: Jenkins
Branch: master

commit 0a717d7085bd2bca7e5408a5c20e8ae7cd055756
Author: Chris Behrens <email address hidden>
Date: Fri Mar 21 19:11:00 2014 +0000

    Use correct project/user for quotas

    This fixes the compute manager to ensure the proper project_id/user_id
    is used when making quota calls by converting most of the compute
    manager code to use the new objects. This does not change the RPC
    messages to the manager, yet.

    Change-Id: I50601d12edef735f3c01ad73445e0826d05efc51
    Closes-bug: 1271541

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

Fix proposed to branch: stable/icehouse
Review: https://review.openstack.org/99215

Thierry Carrez (ttx)
Changed in nova:
milestone: none → juno-1
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/icehouse)

Reviewed: https://review.openstack.org/99215
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=0994254867c0ee7bab7fc5ca9176c588f926fe00
Submitter: Jenkins
Branch: stable/icehouse

commit 0994254867c0ee7bab7fc5ca9176c588f926fe00
Author: Chris Behrens <email address hidden>
Date: Fri Mar 21 19:11:00 2014 +0000

    Use correct project/user for quotas

    This fixes the compute manager to ensure the proper project_id/user_id
    is used when making quota calls by converting most of the compute
    manager code to use the new objects. This does not change the RPC
    messages to the manager, yet.

    Change-Id: I50601d12edef735f3c01ad73445e0826d05efc51
    Closes-bug: 1271541
    (cherry picked from commit 0a717d7085bd2bca7e5408a5c20e8ae7cd055756)

tags: added: in-stable-icehouse
Chuck Short (zulcss)
tags: removed: icehouse-backport-potential
Thierry Carrez (ttx)
Changed in nova:
milestone: juno-1 → 2014.2
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.