# List your volumes openstack volume list openstack volume type list --public --long openstack volume backend pool list cinder --os-volume-api-version 3.50 attachment-delete <attachment_id> openstack volume set --non-bootable <VOLUME_ID>
Search for multiple volume attachment ids
# search for double attachments openstack volume list --all-projects -c ID -c "Attached to" | egrep "Attached.*Attached" # search in DB DB_PASS=$(grep nova_database_password /etc/kolla/passwords.yml | cut -d " " -f2) mysql -h db.service.example.com --password=${DB_PASS} -P 3306 -u nova -D nova -e " select * FROM block_device_mapping where attachment_id in ( SELECT attachment_id FROM block_device_mapping where attachment_id is not null and deleted = 0 group by attachment_id having count(*) > 1 ) " # SQL mysql -h db.service.example.com --password=${DB_PASS} -P 3306 -u nova -D nova -e "select * from block_device_mapping" | grep 1234567890-1111-33333-a400-111111111111 mysql -h db.service.example.com --password=${DB_PASS} -P 3306 -u nova -D nova -e "select * from block_device_mapping where volume_id = '1234567890-1111-33333-a400-111111111111" SELECT volume_id FROM block_device_mapping where volume_id is not null and deleted = 0 group by volume_id having count(*) > 1
(Force) delete volume
cinder reset-state --state available --attach-status detached ${VOLUME_ID} openstack volume delete ${VOLUME_ID}
Backup / Snapshot
https://docs.openstack.org/python-openstackclient/latest/cli/command-objects/volume-snapshot.html
for ID in {1..3}; do openstack volume backup create --force --name dev-ceph${ID}-$(date -I) dev-ceph${ID} done openstack volume backup list
Search for non existing Server
comm -1 -3 \ <(openstack server list --all-projects -c ID -f value --sort-column ID) \ <(openstack volume list --all-projects -c "Attached to" -f json | jq -r '.[]."Attached to"[].server_id' | sort -u)
Remove volume with non existing server
# find volumes with non existing server SERVER_IDS=$(comm -1 -3 <(openstack server list --all-projects -c ID -f value --sort-column ID) <(openstack volume list --all-projects -c "Attached to" -f json | jq -r '.[]."Attached to"[].server_id' | sort -u)) for SERVER_ID in ${SERVER_IDS}; do openstack volume list --all-projects | grep ${SERVER_ID} done # detach volume VOLUME_ID=0bbc58dd-7f7e-4de0-9ae9-01228546e781 VOLUME_ATTACHMENT_ID=$(openstack volume show ${VOLUME_ID} -c attachments -f json | jq -r .attachments[].attachment_id) cinder --os-volume-api-version 3.50 attachment-delete ${VOLUME_ATTACHMENT_ID} openstack volume delete ${VOLUME_ID}
Fix disabled server in cinder
mysql cinder -e "update volumes set host='ctl3-dev@ceph1-ec-1#ceph1-ec-1' where host='ctl5-dev@ceph1-ec-1#ceph1-ec-1' and deleted_at is null;"