quota-usage error in soft-delete

Bug #1333145 reported by hzxiongwenwu
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Sergey Nikitin

Bug Description

condition: reclaim_instance_interval > 0 in nova.conf

I am testing soft-delete , found that quota_usages table will lead to error
result. when an instance was soft-deleted , before it was deleted completely by period task i soft-delete it again, the quato_usages table will reduce double resource of this instance.

the reason is that every execution of soft-delete instance, the reservation will commit.

how to fixed it: we should make reservations=None when instance.vm_state='soft-deleted'.

how to reproduct it:

i am project_id='30528b0d602c4a9c9d8b4cd3d416d710', and I have an instance:

ubuntu@xfolsom:/opt/stack/nova$ nova list
+--------------------------------------+------+--------+------------+-------------+------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+------+--------+------------+-------------+------------------+
| 6f6c1258-6eda-43f1-9531-7a4eb0b44724 | test | ACTIVE | - | Running | private=10.0.0.2 |
+--------------------------------------+------+--------+------------+-------------+------------------+

1.first select from quota_usage, the result is :

mysql> select * from quota_usages;
+---------------------+---------------------+------------+----+----------------------------------+-----------------+--------+----------+---------------+---------+----------------------------------+
| created_at | updated_at | deleted_at | id | project_id | resource | in_use | reserved | until_refresh | deleted | user_id |
+---------------------+---------------------+------------+----+----------------------------------+-----------------+--------+----------+---------------+---------+----------------------------------+
| 2014-06-20 08:24:35 | 2014-06-23 08:35:03 | NULL | 1 | 30528b0d602c4a9c9d8b4cd3d416d710 | instances | 1 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:35 | 2014-06-23 08:35:03 | NULL | 2 | 30528b0d602c4a9c9d8b4cd3d416d710 | ram | 64 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:35 | 2014-06-23 08:35:03 | NULL | 3 | 30528b0d602c4a9c9d8b4cd3d416d710 | cores | 1 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:35 | 2014-06-20 08:24:35 | NULL | 4 | 30528b0d602c4a9c9d8b4cd3d416d710 | security_groups | 1 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:36 | 2014-06-23 03:56:03 | NULL | 5 | 30528b0d602c4a9c9d8b4cd3d416d710 | fixed_ips | 1 | 0 | NULL | 0 | NULL |
+---------------------+---------------------+------------+----+----------------------------------+-----------------+--------+----------+---------------+---------+----------------------------------+
5 rows in set (0.00 sec)

2.using nova-network, set reclaim_instance_interval=600 in nova.conf.
3.nova delete 6f6c1258-6eda-43f1-9531-7a4eb0b44724
4. select from quota_usages, result is :

mysql> select * from quota_usages;
+---------------------+---------------------+------------+----+----------------------------------+-----------------+--------+----------+---------------+---------+----------------------------------+
| created_at | updated_at | deleted_at | id | project_id | resource | in_use | reserved | until_refresh | deleted | user_id |
+---------------------+---------------------+------------+----+----------------------------------+-----------------+--------+----------+---------------+---------+----------------------------------+
| 2014-06-20 08:24:35 | 2014-06-23 08:42:30 | NULL | 1 | 30528b0d602c4a9c9d8b4cd3d416d710 | instances | 0 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:35 | 2014-06-23 08:42:30 | NULL | 2 | 30528b0d602c4a9c9d8b4cd3d416d710 | ram | 0 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:35 | 2014-06-23 08:42:30 | NULL | 3 | 30528b0d602c4a9c9d8b4cd3d416d710 | cores | 0 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:35 | 2014-06-20 08:24:35 | NULL | 4 | 30528b0d602c4a9c9d8b4cd3d416d710 | security_groups | 1 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:36 | 2014-06-23 03:56:03 | NULL | 5 | 30528b0d602c4a9c9d8b4cd3d416d710 | fixed_ips | 1 | 0 | NULL | 0 | NULL |
+---------------------+---------------------+------------+----+----------------------------------+-----------------+--------+----------+---------------+---------+----------------------------------+
5 rows in set (0.00 sec)

5. nova delete 6f6c1258-6eda-43f1-9531-7a4eb0b44724 again

then select from quota_usages, result is :

mysql> select * from quota_usages;
+---------------------+---------------------+------------+----+----------------------------------+-----------------+--------+----------+---------------+---------+----------------------------------+
| created_at | updated_at | deleted_at | id | project_id | resource | in_use | reserved | until_refresh | deleted | user_id |
+---------------------+---------------------+------------+----+----------------------------------+-----------------+--------+----------+---------------+---------+----------------------------------+
| 2014-06-20 08:24:35 | 2014-06-23 08:43:38 | NULL | 1 | 30528b0d602c4a9c9d8b4cd3d416d710 | instances | -1 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:35 | 2014-06-23 08:43:38 | NULL | 2 | 30528b0d602c4a9c9d8b4cd3d416d710 | ram | -64 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:35 | 2014-06-23 08:43:38 | NULL | 3 | 30528b0d602c4a9c9d8b4cd3d416d710 | cores | -1 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:35 | 2014-06-20 08:24:35 | NULL | 4 | 30528b0d602c4a9c9d8b4cd3d416d710 | security_groups | 1 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:36 | 2014-06-23 03:56:03 | NULL | 5 | 30528b0d602c4a9c9d8b4cd3d416d710 | fixed_ips | 1 | 0 | NULL | 0 | NULL |
+---------------------+---------------------+------------+----+----------------------------------+-----------------+--------+----------+---------------+---------+----------------------------------+
5 rows in set (0.00 sec)

oh my god!!! instance in_use is -1 and ram in_use is -64Mb, do you think this is right?

6.nova restore 6f6c1258-6eda-43f1-9531-7a4eb0b44724
 now the db result is:

mysql> select * from quota_usages;
+---------------------+---------------------+------------+----+----------------------------------+-----------------+--------+----------+---------------+---------+----------------------------------+
| created_at | updated_at | deleted_at | id | project_id | resource | in_use | reserved | until_refresh | deleted | user_id |
+---------------------+---------------------+------------+----+----------------------------------+-----------------+--------+----------+---------------+---------+----------------------------------+
| 2014-06-20 08:24:35 | 2014-06-23 08:44:41 | NULL | 1 | 30528b0d602c4a9c9d8b4cd3d416d710 | instances | 2 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:35 | 2014-06-23 08:44:41 | NULL | 2 | 30528b0d602c4a9c9d8b4cd3d416d710 | ram | 128 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:35 | 2014-06-23 08:44:41 | NULL | 3 | 30528b0d602c4a9c9d8b4cd3d416d710 | cores | 2 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:35 | 2014-06-20 08:24:35 | NULL | 4 | 30528b0d602c4a9c9d8b4cd3d416d710 | security_groups | 1 | 0 | NULL | 0 | e522bb6fecaa4a69b6d7df69211dab13 |
| 2014-06-20 08:24:36 | 2014-06-23 03:56:03 | NULL | 5 | 30528b0d602c4a9c9d8b4cd3d416d710 | fixed_ips | 1 | 0 | NULL | 0 | NULL |
+---------------------+---------------------+------------+----+----------------------------------+-----------------+--------+----------+---------------+---------+----------------------------------+
5 rows in set (0.00 sec)

obviously, the result in db is error.now I have only one instance, but in db, i have used 2 instances, 2 cores , 128Mb ram and so on.

The correct way is that we should not allow deleting instance which status in soft-delete.

Tags: quota
hzxiongwenwu (xwwzzy)
description: updated
hzxiongwenwu (xwwzzy)
Changed in nova:
assignee: nobody → hzxiongwenwu (xwwzzy)
hzxiongwenwu (xwwzzy)
description: updated
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/102153

Changed in nova:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by hzxiongwenwu (<email address hidden>) on branch: master
Review: https://review.openstack.org/101855

Revision history for this message
Sean Dague (sdague) wrote :

Patch abandoned, not in progress any more

Changed in nova:
status: In Progress → Confirmed
importance: Undecided → Medium
tags: added: quota
Changed in nova:
assignee: hzxiongwenwu (xwwzzy) → nobody
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Joe Gordon (<email address hidden>) on branch: master
Review: https://review.openstack.org/102153
Reason: Patch is stalled waiting for the author, looks like this has been abandoned. Feel free to restore.

Changed in nova:
assignee: nobody → Sergey Nikitin (snikitin)
Changed in nova:
status: Confirmed → In Progress
Changed in nova:
status: In Progress → Confirmed
Revision history for this message
Sergey Nikitin (snikitin) wrote :
Changed in nova:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/128848
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=4546ce0012b526cd370533ba5a3f2f4107d249a2
Submitter: Jenkins
Branch: master

commit 4546ce0012b526cd370533ba5a3f2f4107d249a2
Author: Sergey Nikitin <email address hidden>
Date: Thu Oct 16 12:31:13 2014 +0400

    Fixed quotas double decreasing problem

    When we delete vm with status "soft-delete" we shouldn't change
    quota values because they were changed during soft-deleting.

    Closes-bug: #1333145
    Change-Id: I3ed7b3245b8908faa02903c74503918f061016bd

Changed in nova:
status: In Progress → Fix Committed
Revision history for this message
Patrick Crews (patrick-crews) wrote :
Thierry Carrez (ttx)
Changed in nova:
milestone: none → kilo-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: kilo-1 → 2015.1.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.