Skip to content

Commit

Permalink
Merge "Destroy src and dest instances when deleting in RESIZE_VERIFY"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Mar 26, 2012
2 parents 81587ba + d3b01e4 commit a003e45
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions nova/compute/api.py
Expand Up @@ -899,16 +899,30 @@ def soft_delete(self, context, instance):
def _delete(self, context, instance):
host = instance['host']
try:
if host:
self.update(context,
instance,
task_state=task_states.DELETING,
progress=0)

self._cast_compute_message('terminate_instance',
context, instance)
else:
self.db.instance_destroy(context, instance['id'])
if not host:
# Just update database, nothing else we can do
return self.db.instance_destroy(context, instance['id'])

self.update(context,
instance,
task_state=task_states.DELETING,
progress=0)

if instance['task_state'] == task_states.RESIZE_VERIFY:
# If in the middle of a resize, use confirm_resize to
# ensure the original instance is cleaned up too
migration_ref = self.db.migration_get_by_instance_and_status(
context, instance['uuid'], 'finished')
if migration_ref:
src_host = migration_ref['source_compute']
params = {'migration_id': migration_ref['id']}
# Call since this can race with the terminate_instance
self._call_compute_message('confirm_resize', context,
instance, host=src_host,
params=params)

self._cast_compute_message('terminate_instance',
context, instance)
except exception.InstanceNotFound:
# NOTE(comstud): Race condition. Instance already gone.
pass
Expand Down

0 comments on commit a003e45

Please sign in to comment.