Detaching volumes as a non-admin
Problem
Currently within the Flexi environment we have a few issues with detaching of volumes
When deleting instances that are backed by volumes the volume gets stuck in a attached state to the instance that doesn't exist and you are unable to delete that volume without admin intervention
When manually detaching a volume from the instance it doesn't detach at all, example would be another volume that you have attached to drive additional space
When resizing an instance
Solution
All 3 issues will follow a similar path to detach the volume, You will need to run the following commands in order as if you delete the instance prior to getting this information then the volume will be stuck attached to the non-existent instance and require intervention.
You will need the instance ID to complete this, you will also need to set your
OS_VOLUME_API_VERSION
to 3.27$ export OS_VOLUME_API_VERSION=3.27
Take note of the Instance ID either from the Horizon Dashboard or the CLI and run
$ openstack server volume list -f json INSTANCE_ID EXAMPLE Command and Response below $ openstack server volume list -f json bf2d1e8e-c588-4d84-bfc0-0e302e7f9534 [ { "Device": "/dev/vda", "Server ID": "bf2d1e8e-c588-4d84-bfc0-0e302e7f9534", "Volume ID": "6d471c91-8bf9-4272-8cef-80a0d5414b8b", "Tag": null, "Delete On Termination?": false, "Attachment ID": "fe00ded8-5058-495c-841a-2d3630a50539", "BlockDeviceMapping UUID": "5e579154-2ffb-4067-afdf-31f1628ee7f4" } ]
Take note of the Attachment ID that is returned, if you have multiple volumes attached there will be multiple ID’s returned
ONLY RUN BELOW IF YOUR DELETING THE INSTANCE
Take the instance ID and delete it$ openstack server delete INSTANCE_ID
For each volume attachment ID from the response in step 2 run the following
The volume will now be detached and you are free to delete it or boot another instance from it
This is a current non-admin work around for the current issue we have with the detaching of volumes, always be careful when deleting anything as deletes are non recoverable.
If resizing an instance it would be best to open an support ticket so that we can help as this requires detaching of the volume from an instance that is not going to be deleted.