Ensure LiveMigrationFailed exception is raised
In cases where the live migration recovery method raised an exception, the LiveMigrationFailed exception was not being raised. Change-Id: I583901fe58363c7413e13368e542f2180953f9b6
This commit is contained in:
@@ -1136,6 +1136,22 @@ class TestPowerVMDriver(test.TestCase):
|
||||
self.lpm.rollback_live_migration.assert_called_once_with('context')
|
||||
self.assertEqual(0, mock_post_meth.call_count)
|
||||
|
||||
# Ensure we get LiveMigrationFailed even if recovery fails.
|
||||
self._setup_lpm()
|
||||
mock_post_meth.reset_mock()
|
||||
mock_rec_meth.reset_mock()
|
||||
self.lpm.live_migration.side_effect = ValueError()
|
||||
# Cause the recovery method to fail with an exception.
|
||||
mock_rec_meth.side_effect = ValueError()
|
||||
self.assertRaises(
|
||||
lpm.LiveMigrationFailed, self.drv.live_migration,
|
||||
'context', self.lpm_inst, 'dest', mock_post_meth, mock_rec_meth,
|
||||
'block_mig', 'migrate_data')
|
||||
mock_rec_meth.assert_called_once_with(
|
||||
'context', self.lpm_inst, 'dest', mock.ANY, mock.ANY)
|
||||
self.lpm.rollback_live_migration.assert_called_once_with('context')
|
||||
self.assertEqual(0, mock_post_meth.call_count)
|
||||
|
||||
def test_rollbk_lpm_dest(self):
|
||||
self.drv.rollback_live_migration_at_destination(
|
||||
'context', self.lpm_inst, 'network_info', 'block_device_info')
|
||||
|
||||
@@ -1083,8 +1083,13 @@ class PowerVMDriver(driver.ComputeDriver):
|
||||
"""
|
||||
LOG.warn(_LW("Rolling back live migration."),
|
||||
instance=instance)
|
||||
mig.rollback_live_migration(context)
|
||||
recover_method(context, instance, dest, block_migration, migrate_data)
|
||||
try:
|
||||
mig.rollback_live_migration(context)
|
||||
recover_method(context, instance, dest, block_migration,
|
||||
migrate_data)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
|
||||
raise lpm.LiveMigrationFailed(name=instance.name,
|
||||
reason=six.text_type(ex))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user