现象:创建的卷虚机人为或代码干预导致虚机删除掉但是卷还在in-use的状态,此种情况想要detach卷报错虚机不存在,想删除卷也删不掉
原因为: nova删除虚机时自动分离卷,但由于rabbitmq或者其他原因导致卸载卷不成功,但nova未能对此结果处理,还是将虚机删除掉了,就会导致这种情况
#可以发现虚拟机已经删除掉,但是卷还在挂载着
[root@controller ~]# openstack volume list
+--------------------------------------+------+--------+------+---------------------------------------------------------------+
| ID | Name | Status | Size | Attached to |
+--------------------------------------+------+--------+------+---------------------------------------------------------------+
| 77664599-c422-4f32-afe8-49baa5f8c9f2 | | in-use | 20 | Attached to b4c93fae-6177-47c0-bebe-094dd73f2614 on /dev/vda |
+--------------------------------------+------+--------+------+---------------------------------------------------------------+
#无法删除的卷,导致报错,提示需要修改卷状态
[root@controller ~]# openstack volume delete 77664599-c422-4f32-afe8-49baa5f8c9f2
Failed to delete volume with name or ID '77664599-c422-4f32-afe8-49baa5f8c9f2': Invalid volume: Volume status must be aor \
error or error_restoring or error_extending or error_managing and must not be migrating, attached, belong to a groupapshots \
or be disassociated from snapshots after volume transfer. (HTTP 400) (Request-ID: req-47970140-7b78-4cd1-b84b-9b5)
1 of 1 volumes failed to delete.
#用命令改变卷的状态为available
[root@controller ~]# cinder reset-state 77664599-c422-4f32-afe8-49baa5f8c9f2 --state available
[root@controller ~]# openstack volume list
+--------------------------------------+------+-----------+------+------------------------------------------------------+
| ID | Name | Status | Size | Attached to |
+--------------------------------------+------+-----------+------+------------------------------------------------------+
| 77664599-c422-4f32-afe8-49baa5f8c9f2 | | available | 20 | Attached to b4c93fae-6177-47c0-bebe-094dd73f2614 on |
+--------------------------------------+------+-----------+------+------------------------------------------------------+
#第二次删除还是导致失败
[root@controller ~]# cinder delete 77664599-c422-4f32-afe8-49baa5f8c9f2
Delete for volume 77664599-c422-4f32-afe8-49baa5f8c9f2 failed: Invalid volume: Volume status must be available or error_restoring \
or error_extending or error_managing and must not be migrating, attached, belong to a group, have snapshots associated from snapshots \
after volume transfer. (HTTP 400) (Request-ID: req-156ca339-2971-4ff3-a7a3-520f3a088a5e)
ERROR: Unable to delete any of the specified volumes.
解决方法如下:
- 在控制节点先show一下问题卷 加上debug 调取接口
cinder --debug show 77664599-c422-4f32-afe8-49baa5f8c9f2
#获取到的链接
http://controller:8776/v3/6535a5a0ef0c4e9caa42912d02bd7d54/volumes/77664599-c422-4f32-afe8-49baa5f8c9f2
- 获取token认证
openstack token issue
#获取的token值
gAAAAABexeM59k1IxnaprSQnMRf0eMI8lBD9Q5jlBC97A-8thQ8PFsljLuxqoGo98cnwPfOAbNny7r0T14etakmsL7Smfmjlb25frlSnSqG5mCZOp5chJ0OYtc7P2paGgjn6STlkGxFoaIH7lCe0ehwB-DjYWrCpjC-oH9Wrh1UwaE4Vvmf29rw
- 最后要去数据库查询
volume_attachment
表格中这个卷对应的挂载的 id
MariaDB [(none)]> use cinder
MariaDB [cinder]> select * from volume_attachment where volume_id='77664599-c422-4f32-afe8-49baa5f8c9f2';
#获取到的id值
5ed3a5ca-c6b3-4fcd-899a-146f3cf9db80
- 将以上查询到的信息集成修复接口
curl -g -i -X POST
http://controller:8776/v3/6535a5a0ef0c4e9caa42912d02bd7d54/volumes/77664599-c422-4f32-afe8-49baa5f8c9f2
/action -H "User-Agent: python-cinderclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token:gAAAAABexeM59k1IxnaprSQnMRf0eMI8lBD9Q5jlBC97A-8thQ8PFsljLuxqoGo98cnwPfOAbNny7r0T14etakmsL7Smfmjlb25frlSnSqG5mCZOp5chJ0OYtc7P2paGgjn6STlkGxFoaIH7lCe0ehwB-DjYWrCpjC-oH9Wrh1UwaE4Vvmf29rw
" -d '{"os-detach": {"attachment_id": "5ed3a5ca-c6b3-4fcd-899a-146f3cf9db80
"}}'
控制节点执行完此命令 重新查询该卷 已经变为了available状态 重新执行cinder delete id 删除掉就可以了;
[root@controller ~]# openstack volume list
+--------------------------------------+------+-----------+------+-------------+
| ID | Name | Status | Size | Attached to |
+--------------------------------------+------+-----------+------+-------------+
| 77664599-c422-4f32-afe8-49baa5f8c9f2 | | available | 20 | |
+--------------------------------------+------+-----------+------+-------------+
[root@controller ~]# cinder delete 77664599-c422-4f32-afe8-49baa5f8c9f2
Request to delete volume 77664599-c422-4f32-afe8-49baa5f8c9f2 has been accepted.
[root@controller ~]# openstack volume list
为空
ceph存储上也被删除
#删除前
[root@cephnode01 ~]# rbd ls volumes
volume-77664599-c422-4f32-afe8-49baa5f8c9f2
#删除后
[root@cephnode01 ~]# rbd ls volumes
为空
网友评论