Cinder volume operations

Delete Orphan volumes

We have some volumes seemingly attached to an instance, but the instance is deleted

Volumes attahced to deleted instance

These can't be deleted

Unable to delete orphan volume

We can reset the state and attachment status

cinder reset-state --state available --attach-status detached <VOLUME_ID>

Volume state changed

And now we're able to delete it

openstack volume delete <VOLUME_ID>

Volume successfully deleted

Delete orphan volumes on offlined hosts

If the host the orphan volumes resided on is offline or decommissioned we might have to remove the volumes from the database manually. Plese try the steps in the Delete Orphan volumes section first!

Note the two volumes stuck in deleting

Volumes stuck in deleting status

sudo mysql

List volumes in deleting

Note that we're dealing with volumes which is NOT attached to anything. If the attach_status is not set to detach we'd probably need to fix other tables as well

use cinder;
select id,status,attach_status,host from volumes where status = 'deleting';
--select id,status,attach_status,host from volumes where id = '<VOLUME_ID>';

Volumes from database view

Let's update the volumes so that the host column is NULL. Note that we also update the status to be able to run the proper delete command from the CLI/API.

update volumes set host = NULL, status = 'available' where id = '<VOLUME_ID>';

Set host to null for volume

Note that we're only updating the record for one volume, we could use the same where clause as previously to do this for all deleting volumes at once

After updating the records we can verify it

select id,status,attach_status,host from volumes where status = 'available';

Verify records

Note that since we've updated the status we can't use the same where clause as before

Now we can exit the database client and go back to the delete command from the openstack cli

openstack volume delete <VOLUME_ID>

Repeat for all volumes that is to be deleted

Verify that volumes are deleted

openstack volume list

Verify deletion of volumes

Note that there might still be references in the database for these volumes and their attachments.

Create volume from image

openstack volume create --size 20 --image ubuntu-22.04 --type nas my-nas-root