summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Lindgren <hanlind@kth.se>2013-04-09 14:55:08 +0200
committerHans Lindgren <hanlind@kth.se>2013-04-09 14:55:08 +0200
commitb5732a454a8221bb98cb6a7241b4d4fc17840c6a (patch)
tree02346cd49e9d85fde14c79500faddf40e6a928f3
parent05f5106c198a596f22adadab1ddf6929ab9c247a (diff)
downloadnova-b5732a454a8221bb98cb6a7241b4d4fc17840c6a.tar.gz
nova-b5732a454a8221bb98cb6a7241b4d4fc17840c6a.tar.xz
nova-b5732a454a8221bb98cb6a7241b4d4fc17840c6a.zip
Catch NoValidHost exception during live-migration
To avoid leaving the instance state as MIGRATING if scheduling of a target host fails, add this exception to the list of exceptions for which the instance task state is reset to None. Resolves bug 1166771. Change-Id: I23343091725051624c0eb0b82e9f03a7f9d5f4f4
-rw-r--r--nova/scheduler/manager.py3
-rw-r--r--nova/tests/scheduler/test_scheduler.py32
2 files changed, 34 insertions, 1 deletions
diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py
index 3124c6af9..c6e1ed390 100644
--- a/nova/scheduler/manager.py
+++ b/nova/scheduler/manager.py
@@ -94,7 +94,8 @@ class SchedulerManager(manager.Manager):
return self.driver.schedule_live_migration(
context, instance, dest,
block_migration, disk_over_commit)
- except (exception.ComputeServiceUnavailable,
+ except (exception.NoValidHost,
+ exception.ComputeServiceUnavailable,
exception.InvalidHypervisorType,
exception.UnableToMigrateToSelf,
exception.DestinationHypervisorTooOld,
diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py
index 8c8181cb1..933b4fc20 100644
--- a/nova/tests/scheduler/test_scheduler.py
+++ b/nova/tests/scheduler/test_scheduler.py
@@ -204,6 +204,38 @@ class SchedulerManagerTestCase(test.TestCase):
self.manager.run_instance(self.context, request_spec,
None, None, None, None, {})
+ def test_live_migration_schedule_novalidhost(self):
+ inst = {"uuid": "fake-instance-id",
+ "vm_state": vm_states.ACTIVE,
+ "task_state": task_states.MIGRATING, }
+
+ dest = None
+ block_migration = False
+ disk_over_commit = False
+
+ self._mox_schedule_method_helper('schedule_live_migration')
+ self.mox.StubOutWithMock(compute_utils, 'add_instance_fault_from_exc')
+ self.mox.StubOutWithMock(db, 'instance_update_and_get_original')
+
+ self.manager.driver.schedule_live_migration(self.context,
+ inst, dest, block_migration, disk_over_commit).AndRaise(
+ exception.NoValidHost(reason=""))
+ db.instance_update_and_get_original(self.context, inst["uuid"],
+ {"vm_state": inst['vm_state'],
+ "task_state": None,
+ "expected_task_state": task_states.MIGRATING,
+ }).AndReturn((inst, inst))
+ compute_utils.add_instance_fault_from_exc(self.context,
+ mox.IsA(conductor_api.LocalAPI), inst,
+ mox.IsA(exception.NoValidHost),
+ mox.IgnoreArg())
+
+ self.mox.ReplayAll()
+ self.assertRaises(exception.NoValidHost,
+ self.manager.live_migration,
+ self.context, inst, dest, block_migration,
+ disk_over_commit)
+
def test_live_migration_compute_service_notavailable(self):
inst = {"uuid": "fake-instance-id",
"vm_state": vm_states.ACTIVE,