1:删除虚拟机时候,volume状态仍然显示为in-use状态,如下:
+--------------------------------+-------------------------------------------------+
| Property | Value |
+--------------------------------+-------------------------------------------------+
| attached_servers | ['3d901b77-6f95-445e-8532-168f8a6674fc'] |
| attachment_ids | ['341dda29-5ccb-47b4-972a-0520e57dc09c'] |
| availability_zone | nova |
| bootable | true |
| consistencygroup_id | None |
| created_at | 2019-11-28T12:35:57.000000 |
| description | None |
| encrypted | False |
| id | 729689e2-eecc-4864-8c7d-6660d3d135b2 |
| metadata | |
| migration_status | None |
| multiattach | False |
| name | back-deleted |
| os-vol-host-attr:host | [email protected]_ceph#tripleo_ceph |
| os-vol-mig-status-attr:migstat | None |
| os-vol-mig-status-attr:name_id | None |
| os-vol-tenant-attr:tenant_id | 063d27fbd6624ae58ad8819eb42f2072 |
| replication_status | None |
| size | 60 |
| snapshot_id | None |
| source_volid | None |
| status | in-use |
| updated_at | 2019-11-28T13:40:27.000000 |
| user_id | ea87cb8468d240b5895054a3c29471ad |
| volume_image_metadata | checksum : f56aee63dd46c37f5d81170fdc000532 |
| | container_format : bare |
| | disk_format : raw |
| | image_id : 8c54da5f-26c9-4cd7-bcc5-512d903e5266 |
| | image_name : vgbackup |
| | min_disk : 0 |
| | min_ram : 0 |
| | size : 52428800 |
| volume_type | tripleo |
+--------------------------------+-------------------------------------------------+
2:用detach命令手动detach时出现如下错误:
[[email protected] ~]# nova volume-detach b258499a-dbf7-4a16-b518-0e5340198839 0e07cf21-dcc8-4c8c-a12b-ce30311068d3
ERROR (CommandError): No server with a name or ID of 'b2bbef8e-016f-403f-86c8-0453617fe687' exists.
3:使用命令行重置状态为available之后,再次删除结果如下:
[[email protected] ~]# cinder delete 0e07cf21-dcc8-4c8c-a12b-ce30311068d3
Delete for volume 0e07cf21-dcc8-4c8c-a12b-ce30311068d3 failed: Invalid volume: Volume status must be available or error or error_restoring or error_extending or error_managing and must not be migrating, attached, belong to a group, have snapshots or be disassociated from snapshots after volume transfer. (HTTP 400) (Request-ID: req-06394748-54ae-4108-8477-282d7d81dcf2)
ERROR: Unable to delete any of the specified volumes.
4:使用cinder --debug show 命令查看对应的url(修复接口),如下:
DEBUG:keystoneauth:GET call to volumev3 for https://overcloud.vim3.com:8776/v3/081932ad7f9a4f91b9acd9a5329ea51b/volumes/729689e2-eecc-4864-8c7d-6660d3d135b2 used request id req-f8b0aa83-6c77-4efe-987f-a592c29a333e
5:获取token,如下
(overcloud) [[email protected] ~]# openstack token issue
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires | 2019-11-29T07:18:49+0000 |
| id | gAAAAABd4LhJiNFkgHvN3V2mSDjNMbQqiKSVXuB2OOcfqYPyK_D4HwhPEIrH8bgX23IsDJ4PR9-SpCMyWxGYNixjhkqY908hseOEnVctsZvhxRSscn0YX9v1OXERXfLRHV5sLmj03uyl5xhOkz8lURyamfBt34RiPQynX3Gz_7WLDG2vrwS5ZxQ |
| project_id | 081932ad7f9a4f91b9acd9a5329ea51b |
| user_id | 8a02a25ba9a542e1af13602dfa5969ca |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
6:获取挂载id,attachment_ids的参数就是挂载id,如下:
+--------------------------------+-------------------------------------------------+
| Property | Value |
+--------------------------------+-------------------------------------------------+
| attached_servers | ['3d901b77-6f95-445e-8532-168f8a6674fc'] |
| attachment_ids | ['341dda29-5ccb-47b4-972a-0520e57dc09c'] |
| availability_zone | nova |
| bootable | true |
| consistencygroup_id | None |
| created_at | 2019-11-28T12:35:57.000000 |
| description | None |
| encrypted | False |
| id | 729689e2-eecc-4864-8c7d-6660d3d135b2 |
| metadata | |
| migration_status | None |
| multiattach | False |
| name | back-deleted |
| os-vol-host-attr:host | [email protected]_ceph#tripleo_ceph |
| os-vol-mig-status-attr:migstat | None |
| os-vol-mig-status-attr:name_id | None |
| os-vol-tenant-attr:tenant_id | 063d27fbd6624ae58ad8819eb42f2072 |
| replication_status | None |
| size | 60 |
| snapshot_id | None |
| source_volid | None |
| status | in-use |
| updated_at | 2019-11-28T13:40:27.000000 |
| user_id | ea87cb8468d240b5895054a3c29471ad |
| volume_image_metadata | checksum : f56aee63dd46c37f5d81170fdc000532 |
| | container_format : bare |
| | disk_format : raw |
| | image_id : 8c54da5f-26c9-4cd7-bcc5-512d903e5266 |
| | image_name : vgbackup |
| | min_disk : 0 |
| | min_ram : 0 |
| | size : 52428800 |
| volume_type | tripleo |
+--------------------------------+-------------------------------------------------+
7:执行以下命令恢复卷的状态:
curl -g -i -X POST https://overcloud.vim3.com:8776/v3/081932ad7f9a4f91b9acd9a5329ea51b/volumes/729689e2-eecc-4864-8c7d-6660d3d135b2/action -H "User-Agent: python-cinderclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token:gAAAAABd4LhJiNFkgHvN3V2mSDjNMbQqiKSVXuB2OOcfqYPyK_D4HwhPEIrH8bgX23IsDJ4PR9-SpCMyWxGYNixjhkqY908hseOEnVctsZvhxRSscn0YX9v1OXERXfLRHV5sLmj03uyl5xhOkz8lURyamfBt34RiPQynX3Gz_7WLDG2vrwS5ZxQ" -d '{"os-detach": {"attachment_id": "341dda29-5ccb-47b4-972a-0520e57dc09c"}}'
返回结果如下:
HTTP/1.1 202 Accepted
Date: Fri, 29 Nov 2019 06:21:11 GMT
Server: Apache
x-compute-request-id: req-0e794ce3-b2cd-4a5c-bbab-eaefea3d4f50
OpenStack-API-Version: volume 3.0
Vary: OpenStack-API-Version
x-openstack-request-id: req-0e794ce3-b2cd-4a5c-bbab-eaefea3d4f50
Content-Length: 0
Content-Type: application/json
8:再次查看volume状态为available,如下:
(overcloud) [[email protected] ~]# cinder show 729689e2-eecc-4864-8c7d-6660d3d135b2
+--------------------------------+-------------------------------------------------+
| Property | Value |
+--------------------------------+-------------------------------------------------+
| attached_servers | [] |
| attachment_ids | [] |
| availability_zone | nova |
| bootable | true |
| consistencygroup_id | None |
| created_at | 2019-11-28T12:35:57.000000 |
| description | None |
| encrypted | False |
| id | 729689e2-eecc-4864-8c7d-6660d3d135b2 |
| metadata | |
| migration_status | None |
| multiattach | False |
| name | back-deleted |
| os-vol-host-attr:host | [email protected]_ceph#tripleo_ceph |
| os-vol-mig-status-attr:migstat | None |
| os-vol-mig-status-attr:name_id | None |
| os-vol-tenant-attr:tenant_id | 063d27fbd6624ae58ad8819eb42f2072 |
| replication_status | None |
| size | 60 |
| snapshot_id | None |
| source_volid | None |
| status | available |
| updated_at | 2019-11-28T13:40:27.000000 |
| user_id | ea87cb8468d240b5895054a3c29471ad |
| volume_image_metadata | checksum : f56aee63dd46c37f5d81170fdc000532 |
| | container_format : bare |
| | disk_format : raw |
| | image_id : 8c54da5f-26c9-4cd7-bcc5-512d903e5266 |
| | image_name : vgbackup |
| | min_disk : 0 |
| | min_ram : 0 |
| | size : 52428800 |
| volume_type | tripleo |
+--------------------------------+-------------------------------------------------+
9:删除卷,cinder delete
(overcloud) [[email protected] ~]# cinder delete 729689e2-eecc-4864-8c7d-6660d3d135b2
Request to delete volume 729689e2-eecc-4864-8c7d-6660d3d135b2 has been accepted.
(overcloud) [[email protected] ~]# cinder show 729689e2-eecc-4864-8c7d-6660d3d135b2
ERROR: No volume with a name or ID of '729689e2-eecc-4864-8c7d-6660d3d135b2' exists.
(overcloud) [[email protected] ~]#
10:猜测出现以上问题的原因:
nova删除虚机时自动detach卷,但由于rabbitmq或者其他原因导致卸载卷不成功,但nova未能对此结果处理,还是将虚机删除掉了,就会导致这种情况
deleting状态删除方式:
1:删除卷时出现卷的状态为deleting的处理方法:
(overcloud) [[email protected] ~]# cinder list
+--------------------------------------+----------+--------------------------------+------+--------------+----------+--------------------------------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+----------+--------------------------------+------+--------------+----------+--------------------------------------+
| 14b11994-7d4e-4499-bd92-337a25d3ad43 | in-use | VIM4CBND1951028-0-cbnd-gluster | 20 | tripleo | false | 99177c50-f41c-4749-b575-7b4789519c5a |
| 16f80d92-fc1d-4893-ad7c-c6fc40a8c543 | in-use | CBND1951104-0-varlog | 50 | tripleo-ceph | false | 4bfccf06-7a15-43fc-a7e5-05121b57f799 |
| 1fca816e-5c55-477b-9a2a-19b11520044a | in-use | VIM4CBND1951028-0-cbnd-metrics | 16 | tripleo | false | 99177c50-f41c-4749-b575-7b4789519c5a |
| 2f081610-4a7b-47f6-bf02-2593e53cb79b | in-use | CBND1951104-0-cbnd-gluster | 20 | tripleo-ceph | false | 4bfccf06-7a15-43fc-a7e5-05121b57f799 |
| 30f999f0-c00f-4281-88ab-6e06aae214e8 | in-use | CBND1951104-0-cbnd-metrics | 16 | tripleo-ceph | false | 4bfccf06-7a15-43fc-a7e5-05121b57f799 |
| 35013dfd-c048-45e4-a5cc-061e165d6349 | deleting | - | 1 | tripleo | false | |
| 3dcebce5-417e-4201-9e23-097c892554f1 | in-use | CBND1951104-0-cbnd-backup | 40 | tripleo-ceph | false | 4bfccf06-7a15-43fc-a7e5-05121b57f799 |
| 46fc194a-6646-4004-8eff-97c38e898a61 | in-use | | 500 | tripleo | true | 7f4f1271-43d9-455a-a377-f4d2b2fbaea5 |
2:重置状态,如下:
cinder reset-state --state available 35013dfd-c048-45e4-a5cc-061e165d6349
3:删除卷
cinder delete 35013dfd-c048-45e4-a5cc-061e165d6349