«

cinder卷删除不掉解决方案

指尖二进制 • 1 年前 • 880 次点击 • OPENSTACK


现象:openstack-M环境创建的卷虚机 人为或代码干预导致虚机删除掉但是卷还在in-use的状态,此种情况想要detach卷报错虚机不存在,想删除卷也删不掉

Delete for volume af804c98-d507-49bb-a651-5da9b1a1865f 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-85242630-1b75-480d-9a25-97b14112138a)
ERROR: Unable to delete any of the specified volumes.

原因为 nova删除虚机时自动detach卷,但由于rabbitmq或者其他原因导致卸载卷不成功,但nova未能对此结果处理,还是将虚机删除掉了,就会导致这种情况

解决方法如下:
在控制节点先show一下问题卷 加上debug 调取接口

[root@XC-tstack-con01 ~(keystone_admin)]# cinder --debug show af804c98-d507-49bb-a651-5da9b1a1865f

获取token认证

openstack token issue

最后还要去数据库查询
volume_attachment表格中这个卷对应的挂载的id

select * from volume_attachment where volume_id='af804c98-d507-49bb-a651-5da9b1a1865f';

以上查询到的信息集成修复接口
curl -g -i -X POST http://10.116.21.250:8776/v3/03b24e64a0d94677b607c4f4df5fd856/volumes/af804c98-d507-49bb-a651-5da9b1a1865f/action -H "User-Agent: python-cinderclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: gAAAAABj22mwoYyvsFL7G6mwR1YOq_DrwvwHZJmm4H1i96Prs1alIO3caoZ6LkKnFkOCXcBWxNsfqLrD5cfy303-1xBBp-iMfLZ2hKqSEnqoLzyOagFLo6PVg3eKxEZXSpTKWtdo3pgRUHgwvISUf0K8Drdzez_92zeyUknShdz-uCzl_f0GRus" -d '{"os-detach": {"attachment_id": "1cd1af02-c38e-404e-896b-96744760f430"}}'

控制节点执行完此命令 重新查询该卷 已经变为了available状态 重新执行cinder delete id 删除掉就可以了;

还没收到回复