Keep instance state if ssh failed during migration
When block-migrating a vm between two compute nodes, if the destination node lacks ssh daemon or refuses ssh connection, the block-migration would fail and cause damage to the vm, vm will be in error state for a certain time. Actually, the VM itself is not changed, the resize action failed at preparation stage, so don't need to set it to 'ERROR' state. Change-Id: I9907fcd9b235b6a9697416b93f561d831eebee6c Closes-Bug: #1406167
This commit is contained in:
parent
713767660b
commit
a7bd611eb2
|
@ -11949,12 +11949,11 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
self.assertFalse(self.copy_or_move_swap_called)
|
||||
self.assertEqual(disk_info_text, out)
|
||||
|
||||
def test_migrate_disk_and_power_off_lvm(self):
|
||||
def _test_migrate_disk_and_power_off_resize_check(self, expected_exc):
|
||||
"""Test for nova.virt.libvirt.libvirt_driver.LibvirtConnection
|
||||
.migrate_disk_and_power_off.
|
||||
"""
|
||||
|
||||
self.flags(images_type='lvm', group='libvirt')
|
||||
disk_info = [{'type': 'raw', 'path': '/dev/vg/disk',
|
||||
'disk_size': '83886080'},
|
||||
{'type': 'raw', 'path': '/dev/disk.local',
|
||||
|
@ -11979,17 +11978,42 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
self.stubs.Set(self.drvr, '_destroy', fake_destroy)
|
||||
self.stubs.Set(self.drvr, 'get_host_ip_addr',
|
||||
fake_get_host_ip_addr)
|
||||
self.stubs.Set(utils, 'execute', fake_execute)
|
||||
|
||||
ins_ref = self._create_instance()
|
||||
flavor = {'root_gb': 10, 'ephemeral_gb': 20}
|
||||
flavor_obj = objects.Flavor(**flavor)
|
||||
|
||||
# Migration is not implemented for LVM backed instances
|
||||
self.assertRaises(exception.MigrationPreCheckError,
|
||||
self.assertRaises(expected_exc,
|
||||
self.drvr.migrate_disk_and_power_off,
|
||||
None, ins_ref, '10.0.0.1', flavor_obj, None)
|
||||
|
||||
def test_migrate_disk_and_power_off_lvm(self):
|
||||
self.flags(images_type='lvm', group='libvirt')
|
||||
|
||||
def fake_execute(*args, **kwargs):
|
||||
pass
|
||||
|
||||
self.stubs.Set(utils, 'execute', fake_execute)
|
||||
|
||||
expected_exc = exception.MigrationPreCheckError
|
||||
self._test_migrate_disk_and_power_off_resize_check(expected_exc)
|
||||
|
||||
def test_migrate_disk_and_power_off_resize_cannot_ssh(self):
|
||||
def fake_execute(*args, **kwargs):
|
||||
raise processutils.ProcessExecutionError()
|
||||
|
||||
def fake_is_storage_shared(dest, inst_base):
|
||||
self.checked_shared_storage = True
|
||||
return False
|
||||
|
||||
self.stubs.Set(self.drvr, '_is_storage_shared_with',
|
||||
fake_is_storage_shared)
|
||||
self.stubs.Set(utils, 'execute', fake_execute)
|
||||
|
||||
expected_exc = exception.InstanceFaultRollback
|
||||
self._test_migrate_disk_and_power_off_resize_check(expected_exc)
|
||||
|
||||
def test_migrate_disk_and_power_off_resize_error(self):
|
||||
instance = self._create_instance()
|
||||
flavor = {'root_gb': 5, 'ephemeral_gb': 10}
|
||||
|
|
|
@ -5834,7 +5834,12 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
# if this fails we pass the exception up the stack so we can catch
|
||||
# failures here earlier
|
||||
if not shared_storage:
|
||||
utils.execute('ssh', dest, 'mkdir', '-p', inst_base)
|
||||
try:
|
||||
utils.execute('ssh', dest, 'mkdir', '-p', inst_base)
|
||||
except processutils.ProcessExecutionError as e:
|
||||
reason = _("not able to execute ssh command: %s") % e
|
||||
raise exception.InstanceFaultRollback(
|
||||
exception.ResizeError(reason=reason))
|
||||
|
||||
self.power_off(instance, timeout, retry_interval)
|
||||
|
||||
|
|
Loading…
Reference in New Issue