现象:P版环境创建的卷虚机 人为或代码干预导致虚机删除掉但是卷还在in-use的状态,此种情况想要detach卷报虚机不存在,
想删除卷也删不掉
Delete for volume b80074d1-b9fa-4833-98d7-e19dfeec00b0 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-744fc7a7-1920-48d3-91b4-b3348962f602)
ERROR: Unable to delete any of the specified volumes.
原因为 nova删除虚机时自动detach卷,但由于rabbitmq或者其他原因导致卸载卷不成功,但nova未能对此结果处理,还是将虚机删除掉了,就会导致这种情况
解决方法如下:
在控制节点先show一下问题卷 加上debug 调取接口
# cinder --debug show d6c76247-ad3b-442e-ae97-98a2ccd74362
# openstack token issue
获取token认证
最后还要去数据库查询
volume_attachment表格中这个卷对应的挂载的id
select * from volume_attachment where volume_id=‘d6c76247-ad3b-442e-ae97-98a2ccd74362‘;
以上查询到的信息集成修复接口
curl -g -i -X POST http://10.76.188.29:8776/v3/81e5890a537a4e70ba4038c15ca55bc4/volumes/d6c76247-ad3b-442e-ae97-98a2ccd74362/action -H "User-Agent: python-cinderclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: gAAAAABc51ltN2C5nhoDAigmpisBL2HnlL9osbTMFOjSnHWnkUK_LqHWi81Jx2r_Iq7XB9p967HnzxOARB3S0b_R4XfvzAA_3KsYdyufvTXjKQS2Lk6Kb3VR8d92SgBb9CB0DL3SbGTjUuj4ZvppTa-dYDLgiO2R6n29BJeJtGyp93GQ73bJE9k" -d ‘{"os-detach": {"attachment_id": "ef3a3d58-b6b3-47bf-98f4-2f6b587eb61c"}}‘
重新查询该卷 已经变为了available状态 重新执行cinder delete id 删除掉就可以了;
原文:https://www.cnblogs.com/jimmyyang/p/10916772.html