diff options
| author | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-03-26 14:58:27 +0000 |
|---|---|---|
| committer | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2012-03-26 21:23:42 +0000 |
| commit | d3b01e4476cbee9fde01238dbdf0a41f0220e3a3 (patch) | |
| tree | ffb4d2def35ba7992b336b6d57bd6be723118da2 | |
| parent | bcae3c0427d78a7ba1b043db60e7aba2eece9695 (diff) | |
| download | nova-d3b01e4476cbee9fde01238dbdf0a41f0220e3a3.tar.gz nova-d3b01e4476cbee9fde01238dbdf0a41f0220e3a3.tar.xz nova-d3b01e4476cbee9fde01238dbdf0a41f0220e3a3.zip | |
Destroy src and dest instances when deleting in RESIZE_VERIFY
Fixes bug 963630
Since deletes are allowed during RESIZE_VERIFY, we need to ensure that
the original instance is also deleted so we don't leak resources.
Change-Id: Ibfd5ad4e427c247f1cd5fddcf4f43b30839a6c4f
| -rw-r--r-- | nova/compute/api.py | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 79e490395..37e136a41 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -899,16 +899,30 @@ class API(base.Base): 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 |
