Ask Your Question
0

Best way to delete VM from database if it is already deleted from computing node [closed]

asked 2016-01-12 09:03:10 -0500

DanielJ gravatar image

Hello all,

have some old virtual machines (VMs) that are in an ERROR state because there was some error during their deletion. If I want to delete them, the machine stays in ERROR state. When I had a look on the compute node, on which it should run, I saw that it was already deleted from libvirt. Thus, there is only the entry in the mysql database remaining.

Deleting this entry via the OpenStack Dashboard, nova delete or nova force-delete results in an error. What is the best way to remove this entry from the database? (I use OpenStack Juno.)

  1. Create a VM manually that fits to the data in the database and then try to delete it with nova.
  2. Change the database manually.

Can you provide me with the required commands for any of both alternatives or a better solution?

Just a remark: If I create new VMs, they are deleted without any errors, now.

Regards,

Daniel

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by DanielJ
close date 2016-01-20 03:59:59.843846

Comments

Can you still see the VMs in error state in the horizon dashboard?

Syed Awais Ali gravatar imageSyed Awais Ali ( 2016-01-12 09:53:01 -0500 )edit

Yes, the horizon dashboard shows the VMs in error state. And it also shows that they are in error state.

DanielJ gravatar imageDanielJ ( 2016-01-13 02:56:15 -0500 )edit

I have tried to manually recreate the VM. Therefore, I used virsh dumpxml for a different instance on the same compute node. Then, I adapted its configuration to the values of the VM in EROR state. I had to outcomment the network interface. Then I started the instance. (to be continued)

DanielJ gravatar imageDanielJ ( 2016-01-19 04:46:20 -0500 )edit

(continued) Then, I reset its state to active with nova. But when I tried to terminate it again, the VM was deleted from the compute node but in nova the VM returned into an error state.

DanielJ gravatar imageDanielJ ( 2016-01-19 04:48:44 -0500 )edit

3 answers

Sort by ยป oldest newest most voted
0

answered 2016-01-20 03:58:11 -0500

DanielJ gravatar image

The problem that I could not terminate the instance was related to the problem that cinder could not detach the volume from the VM (see https://ask.openstack.org/en/question/87681/unable-to-detach-volume-from-instance-during-its-termination-process/ (Unable to detach volume from instance during its termination process)). After solving this issue, the instances could be terminated regularly.

edit flag offensive delete link more
1

answered 2016-01-13 02:44:25 -0500

updated 2016-01-13 02:48:12 -0500

IF you are still able to see the VM in ERROR state in Horizon dashboard then follow these steps


You can delete by resetting the state of the VM

nova reset-state --active {uuid-of-instance}

Check its state by nova list or nova show {uuid-of-instance}

Then try to delete it using command

nova delete {uuid-of-instance}

OR doing the force-delete

nova force-delete {uuid-of-instance}
edit flag offensive delete link more

Comments

I have already tried it. I could reset it into active state but when I want to delete it on any of both ways, it returns in the error state.

DanielJ gravatar imageDanielJ ( 2016-01-13 02:57:40 -0500 )edit

thanks! This is working to me. I removed the stuck VM using nova delete.

Gopalakrishnan S gravatar imageGopalakrishnan S ( 2017-07-28 02:34:58 -0500 )edit
0

answered 2016-01-12 17:43:20 -0500

capsali gravatar image

HERE and HERE

Both are a little outdated, with the latter being way back from 2012 but with a little logic you should be able to delete the instance from mysql. The second link offers the creation of a script for deleteing all instances with error marker in db.

edit flag offensive delete link more

Comments

I would prefer marking the instance as deleted instead of actually deleting it from the database. I also found https://stackoverflow.com/questions/22194965/openstack-can-not-delete-instance-from-dashboard (a description to mark an instance as deleted for Icehouse).

DanielJ gravatar imageDanielJ ( 2016-01-13 03:07:34 -0500 )edit

Since all possible solutions are quite outdated or not for Juno, I am a bit afraid of causing an inconsistency in the database. That is why I hoped to get an already tested solution.

DanielJ gravatar imageDanielJ ( 2016-01-13 03:13:21 -0500 )edit

Well it is tested by me. The only problem will be aditional table dependecies that need to be deleted first prior to deleting the instance from db.

capsali gravatar imagecapsali ( 2016-01-13 09:30:53 -0500 )edit

update instances set deleted='1', vm_state='deleted', deleted_at='now()'' where uuid='$vm_uuid' and project_id='$project_uuid';

will update the status to deleted and not remove it from db

capsali gravatar imagecapsali ( 2016-01-13 09:31:20 -0500 )edit

If I set the instance in the table instances as deleted, will OpenStack automatically, e.g., detach the volume from the machine, free the ip addresses, mark the port of the subnet as deleted, ... ?

DanielJ gravatar imageDanielJ ( 2016-01-13 09:47:43 -0500 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools

2 followers

Stats

Asked: 2016-01-12 09:03:10 -0500

Seen: 7,800 times

Last updated: Jan 20 '16