diff options
author | Jian Wen <jian.wen@canonical.com> | 2013-01-14 19:13:24 +0800 |
---|---|---|
committer | Jian Wen <jian.wen@canonical.com> | 2013-01-31 15:22:43 +0800 |
commit | be62d6a86971abac57a1cc03c985ba1e97fd55cb (patch) | |
tree | 4f0beece6fdf6bec93e18341322ed070d67ca203 /nova/scheduler | |
parent | b7e0c9dd588e5fad1cf4e3eb3f71828ca0122a55 (diff) | |
download | nova-be62d6a86971abac57a1cc03c985ba1e97fd55cb.tar.gz nova-be62d6a86971abac57a1cc03c985ba1e97fd55cb.tar.xz nova-be62d6a86971abac57a1cc03c985ba1e97fd55cb.zip |
Handle compute node not available for live migration
This patch handles exception.ComputeServiceUnavailable by restoring
instance's vm_state and instance's task_state after live migration
failure caused by unavailable source/dest compute node.
Raises detailed HTTPBadRequest explanation for this exception.
Fixes bug 973393 and bug 1051881
Change-Id: If825b61fad9c4e3030f2e6c5002907255eaf3661
Diffstat (limited to 'nova/scheduler')
-rw-r--r-- | nova/scheduler/driver.py | 5 | ||||
-rw-r--r-- | nova/scheduler/manager.py | 11 |
2 files changed, 15 insertions, 1 deletions
diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 01bef4185..dc945a515 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -209,7 +209,10 @@ class Scheduler(object): """ # Checking dest exists and compute node. - dservice_ref = db.service_get_by_compute_host(context, dest) + try: + dservice_ref = db.service_get_by_compute_host(context, dest) + except exception.NotFound: + raise exception.ComputeServiceUnavailable(host=dest) # Checking dest host is alive. if not self.servicegroup_api.service_is_up(dservice_ref): diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py index e6bf1a293..830d61852 100644 --- a/nova/scheduler/manager.py +++ b/nova/scheduler/manager.py @@ -24,6 +24,7 @@ Scheduler Service import sys from nova.compute import rpcapi as compute_rpcapi +from nova.compute import task_states from nova.compute import utils as compute_utils from nova.compute import vm_states from nova.conductor import api as conductor_api @@ -92,6 +93,16 @@ class SchedulerManager(manager.Manager): return self.driver.schedule_live_migration( context, instance, dest, block_migration, disk_over_commit) + except exception.ComputeServiceUnavailable as ex: + request_spec = {'instance_properties': { + 'uuid': instance['uuid'], }, + } + with excutils.save_and_reraise_exception(): + self._set_vm_state_and_notify('live_migration', + dict(vm_state=instance['vm_state'], + task_state=None, + expected_task_state=task_states.MIGRATING,), + context, ex, request_spec) except Exception as ex: with excutils.save_and_reraise_exception(): self._set_vm_state_and_notify('live_migration', |