HiHere,there is a problem to discuss with you.Problem: a volume may leave over 
when we delete an instance   Description:Here, two scenes may cause that a 
volume is legacy when we delete instance whose task_state is 
block_device_mapping .The first scene is that using the boot volume created by 
image creates instance; The other scene is that using image create instance 
with a volume created through a image.
Reason:Through analyzing, we find that the volume id is not update to 
block_device_mapping table in DB until a volume created by an image through 
setting parameters in Blocking Device Mapping v2 is attached to an instance 
completely.If we delete the instance before the volume id is not update to the 
block_device_mapping table, the problem mentioned above will occur.
Although the reason of the problem is found, I want to discuss the solution 
about it with you   
Two examples to reproduce the problem on latest icehousce:
1. the first scene
(1)root@devstack:~# nova list
+----+------+--------+------------+-------------+----------+
| ID | Name | Status | Task State | Power State | Networks |
+----+------+--------+------------+-------------+----------+
+----+------+--------+------------+-------------+----------+
(2)root@devstack:~# nova boot --flavor m1.tiny --block-device 
id=61ebee75-5883-49a3-bf85-ad6f6c29fc1b,source=image,dest=volume,device=vda,size=1,shutdown=removed,bootindex=0
 --nic net-id=354ba9ac-e6a7-4fd6-a49f-6ae18a815e95 tralon_test
root@devstack:~# nova list
+--------------------------------------+-------------+--------+----------------------+-------------+-------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+-------------+--------+----------------------+-------------+-------------------+
| 57cbb39d-c93f-44eb-afda-9ce00110950d | tralon_test | BUILD | 
block_device_mapping | NOSTATE | private=10.0.0.20 |
+--------------------------------------+-------------+--------+----------------------+-------------+-------------------+
(3)root@devstack:~# nova delete tralon_test
root@devstack:~# nova list
+----+------+--------+------------+-------------+----------+
| ID | Name | Status | Task State | Power State | Networks |
+----+------+--------+------------+-------------+----------+
+----+------+--------+------------+-------------+----------+
(4) root@devstack:~# cinder list
+--------------------------------------+-----------+------+------+-------------+----------+--------------------------------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+------+------+-------------+----------+--------------------------------------+
| 3e5579a9-5aac-42b6-9885-441e861f6cc0 | available | None | 1 | None | false | |
| a4121322-529b-4223-ac26-0f569dc7821e | available | | 1 | None | true | |
| a7ad846b-8638-40c1-be42-f2816638a917 | in-use | | 1 | None | true | 
57cbb39d-c93f-44eb-afda-9ce00110950d |
+--------------------------------------+-----------+------+------+-------------+----------+--------------------------------------+
we can see that the instance 57cbb39d-c93f-44eb-afda-9ce00110950d was deleted 
while the volume still exists with the "in-use" status2. the scend scene
 (1)root@devstack:~# nova list
+----+------+--------+------------+-------------+----------+
| ID | Name | Status | Task State | Power State | Networks |
+----+------+--------+------------+-------------+----------+
+----+------+--------+------------+-------------+----------+
(2)root@devstack:~# nova boot --flavor m1.tiny --image 
61ebee75-5883-49a3-bf85-ad6f6c29fc1b --nic 
net-id=354ba9ac-e6a7-4fd6-a49f-6ae18a815e95 --block-device 
id=61ebee75-5883-49a3-bf85-ad6f6c29fc1b,source=image,dest=volume,device=vdb,size=1,shutdown=removed
 tralon_image_instance
root@devstack:~# nova list
+--------------------------------------+-----------------------+--------+----------------------+-------------+-------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+-----------------------+--------+----------------------+-------------+-------------------+
| 25bcfe84-0c3f-40d3-a917-4791e092fa06 | tralon_image_instance | BUILD | 
block_device_mapping | NOSTATE | private=10.0.0.26 |
+--------------------------------------+-----------------------+--------+----------------------+-------------+-------------------+
(3)root@devstack:~# nova delete 25bcfe84-0c3f-40d3-a917-4791e092fa06
  ( 4 ) root@devstack:~# nova list
+----+------+--------+------------+-------------+----------+
| ID | Name | Status | Task State | Power State | Networks |
+----+------+--------+------------+-------------+----------+
+----+------+--------+------------+-------------+----------+
 (5) root@devstack:~# cinder list
+--------------------------------------+-----------+------+------+-------------+----------+--------------------------------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+------+------+-------------+----------+--------------------------------------+
| 3e5579a9-5aac-42b6-9885-441e861f6cc0 | available | None | 1 | None | false | |
| a7ad846b-8638-40c1-be42-f2816638a917 | in-use | | 1 | None | true | 
57cbb39d-c93f-44eb-afda-9ce00110950d |
| f3df0f15-6c9d-4084-8fb5-dc2826bf3eb0 | in-use | | 1 | None | true | 
25bcfe84-0c3f-40d3-a917-4791e092fa06 |
+--------------------------------------+-----------+------+------+-------------+----------+--------------------------------------+
so, the instance 25bcfe84-0c3f-40d3-a917-4791e092fa06 was deleted while the 
volume f3df0f15-6c9d-4084-8fb5-dc2826bf3eb0 still exists with the "in-use" 
status                                     
_______________________________________________
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to