Skip to content

Instantly share code, notes, and snippets.

@smurugap
Created April 9, 2018 22:22
Show Gist options
  • Save smurugap/c477f0f4d2a93f5902a8cbc71398292f to your computer and use it in GitHub Desktop.
Save smurugap/c477f0f4d2a93f5902a8cbc71398292f to your computer and use it in GitHub Desktop.
DB changes to delete a VM stuck in ‘error’ or ‘deleting’ state
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE FROM security_group_instance_association WHERE instance_uuid IN (SELECT uuid FROM instances WHERE vm_state = "error");'
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE FROM block_device_mapping WHERE instance_uuid IN (SELECT uuid FROM instances WHERE vm_state = "error");'
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE FROM instance_info_caches WHERE instance_uuid IN (SELECT uuid FROM instances WHERE vm_state = "error");'
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE FROM instance_system_metadata WHERE instance_uuid IN (SELECT uuid FROM instances WHERE vm_state = "error");'
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE FROM instance_faults WHERE instance_uuid IN (SELECT uuid FROM instances WHERE vm_state = "error");'
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE FROM instance_actions_events WHERE action_id IN (SELECT id FROM instance_actions where instance_uuid IN (SELECT uuid FROM instances WHERE vm_state = "error"));'
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE FROM instance_actions WHERE instance_uuid IN (SELECT uuid FROM instances WHERE vm_state = "error");'
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; UPDATE fixed_ips SET allocated = 0 WHERE instance_uuid IN (SELECT uuid FROM instances WHERE vm_state = "error");'
mysql -uroot -p$(cat /etc/contrail/mysql.token) -hlocalhost -e 'USE nova; DELETE FROM instances WHERE vm_state = "error";'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment