Ask Your Question
0

Detach volume from non-existing instance

asked 2019-04-24 09:22:23 -0600

ICBeter gravatar image

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...

edit retag flag offensive close merge delete

Comments

If the instance doesn't exist anymore, you can simply reset the volume state to "available": openstack volume set --state available <VOLUME>

eblock gravatar imageeblock ( 2019-04-26 04:37:25 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2019-04-29 03:10:19 -0600

ICBeter gravatar image

updated 2019-04-29 03:10:58 -0600

Thank you for your comment, eblock. But it does not work:

root@controller:~# openstack volume set --state available 211ea613-442e-42db-9438-e51fe2f46487
root@controller:~# 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-aaad4a9f-b618-4761-baf9-298073ea023e)
1 of 1 volumes failed to delete.
root@controller:~# 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'}] |
...
| status                         | available
edit flag offensive delete link more

Comments

1

Of course, I forgot to mention attach-status. You should also reset that: cinder reset-state --state available --attach-status detached 211ea613-442e-42db-9438-e51fe2f46487

eblock gravatar imageeblock ( 2019-04-29 08:19:06 -0600 )edit

Thanks, eblock. That worked!

ICBeter gravatar imageICBeter ( 2019-05-20 04:19:23 -0600 )edit
0

answered 2019-05-11 20:50:56 -0600

Hi @ICBetter!

Normally when this happens is due a missing request via your MQ or some event that is not trigered.

If the solution with the state doesn't work after some time, there are several ways to do that. But, the best way I've found was to do it directly from the DB. This solution is a litle bit tricky since it's required to modify 2 entries on the cinder and nova database and then delete the mapping for the volume attached on instance in nova DB.

Steps:

  • Go to a controller node. Access the MariaDB container. Access the Database.
  • Detach volume from cinder and Updated the volume status
    MariaDB [(none)]> use cinder;
    MariaDB [(cinder)]> update cinder.volumes set attach_status='detached',status='available'  where id='$volume_uuid';
  • Changed to nova DB
   MariaDB [(none)]> use nova;
  • Deleted the instance entry for that volume on the mapping table
   MariaDB [(nova)]> delete from block_device_mapping where not deleted and volume_id='$volume_uuid';
  • Finally, updated the nova bootindex on the mapping table for the volume root file system
   MariaDB [(nova)]> update nova.block_device_mapping  set boot_index=0 where not deleted and volume_id='$volume_uuid';

This two links can provide you more information:

https://raymii.org/s/articles/Fix_inc...

https://ask.openstack.org/en/question...

Hope this works for you as worked for me :D

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2019-04-24 09:22:23 -0600

Seen: 1,017 times

Last updated: May 11