summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Lau <jay.lau.513@gmail.com>2013-05-21 20:56:06 +0800
committerJay Lau <jay.lau.513@gmail.com>2013-06-09 12:09:34 +0800
commitf396f75d14f9da97a566e2e5607f537b07a6803a (patch)
treeb669ac494586f518aab9c28bcb3c23a07b953342
parente0142d0f63bf64a07db3bd3b840fc2072d2e6ca3 (diff)
downloadnova-f396f75d14f9da97a566e2e5607f537b07a6803a.tar.gz
nova-f396f75d14f9da97a566e2e5607f537b07a6803a.tar.xz
nova-f396f75d14f9da97a566e2e5607f537b07a6803a.zip
Put VM UUID to live migration error notification
If live migration encounter some exception before nova scheduler cast message to nova compute, nova scheduler will set the VM state to ERROR and send notification, but the notification do not include VM UUID, this might cause some problem if some components want to handle the notification since those components will not able to know the VM UUID about the notification. The solution is add UUID to live migration error notification so other components can get the related notification correctly. Fix bug 1182117 Change-Id: Id101f9e2a689a02d1604c12cd7677e0975bd7428
-rw-r--r--nova/scheduler/manager.py5
-rw-r--r--nova/tests/scheduler/test_scheduler.py30
2 files changed, 34 insertions, 1 deletions
diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py
index ca7cd956f..52ef71e62 100644
--- a/nova/scheduler/manager.py
+++ b/nova/scheduler/manager.py
@@ -123,10 +123,13 @@ class SchedulerManager(manager.Manager):
expected_task_state=task_states.MIGRATING,),
context, ex, request_spec)
except Exception as ex:
+ request_spec = {'instance_properties': {
+ 'uuid': instance['uuid'], },
+ }
with excutils.save_and_reraise_exception():
self._set_vm_state_and_notify('live_migration',
{'vm_state': vm_states.ERROR},
- context, ex, {})
+ context, ex, request_spec)
def run_instance(self, context, request_spec, admin_password,
injected_files, requested_networks, is_first_time,
diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py
index f4f607647..84a6a023f 100644
--- a/nova/tests/scheduler/test_scheduler.py
+++ b/nova/tests/scheduler/test_scheduler.py
@@ -277,6 +277,36 @@ class SchedulerManagerTestCase(test.TestCase):
self.context, inst, dest, block_migration,
disk_over_commit)
+ def test_live_migration_set_vmstate_error(self):
+ inst = {"uuid": "fake-instance-id",
+ "vm_state": vm_states.ACTIVE, }
+
+ dest = 'fake_host'
+ 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(
+ ValueError)
+ db.instance_update_and_get_original(self.context, inst["uuid"],
+ {"vm_state": vm_states.ERROR,
+ }).AndReturn((inst, inst))
+ compute_utils.add_instance_fault_from_exc(self.context,
+ mox.IsA(conductor_api.LocalAPI), inst,
+ mox.IsA(ValueError),
+ mox.IgnoreArg())
+
+ self.mox.ReplayAll()
+ self.stub_out_client_exceptions()
+ self.assertRaises(ValueError,
+ self.manager.live_migration,
+ self.context, inst, dest, block_migration,
+ disk_over_commit)
+
def test_prep_resize_no_valid_host_back_in_active_state(self):
fake_instance_uuid = 'fake-instance-id'
fake_instance = {'uuid': fake_instance_uuid}