Detach volume from non-existing instance
I have a volume that is attached to an already deleted instance. No idea how this happend, but I cannot delete this volume as long as it is still attached to something:
root@controller:/opt/scripts# openstack volume show 211ea613-442e-42db-9438-e51fe2f46487
+--------------------------------+----------------------------------------+
| Field | Value +--------------------------------+----------------------------------------+
| attachments | [{u'server_id': u'aa04d3e1-ffd7-48ee-af56-37942661598f', u'attachment_id': u'0d01ed31-2912-4aad-b142-657775dbd1de', u'attached_at': u'2018-06-01T20:05:15.000000', u'host_name': u'compute1', u'volume_id': u'211ea613-442e-42db-9438-e51fe2f46487', u'device': u'/dev/vda', u'id': u'211ea613-442e-42db-9438-e51fe2f46487'}] |
but:
root@controller:/opt/scripts# nova volume-detach aa04d3e1-ffd7-48ee-af56-37942661598f 211ea613-442e-42db-9438-e51fe2f46487
ERROR (CommandError): No server with a name or ID of 'aa04d3e1-ffd7-48ee-af56-37942661598f' exists.
root@controller:/opt/scripts# openstack volume delete 211ea613-442e-42db-9438-e51fe2f46487
Failed to delete volume with name or ID '211ea613-442e-42db-9438-e51fe2f46487': 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-9e84c6d4-de2b-4f64-b1ef-2870e431e8b2)
1 of 1 volumes failed to delete.
I have no idea what to do now...
If the instance doesn't exist anymore, you can simply reset the volume state to "available":
openstack volume set --state available <VOLUME>