hyper-v: Copies back files on failed migration
On cold migration, the contents of the instance folder are copied to the new host. The original folder cannot be removed because the VM configuration files cannot be deleted until the VM is destroyed. Because of this, when the migration fails to copy the files, it will try to revert this through folder renaming. Since the original folder still exists, an exception is raised. Change-Id: Ia42ed873924999d57336a105bcaa2b856f3a3a9d Closes-Bug: #1555699
This commit is contained in:
parent
dae13c5153
commit
9740e18a31
@ -129,10 +129,12 @@ class MigrationOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
expected = [mock.call(mock.sentinel.dest_path),
|
||||
mock.call(mock.sentinel.revert_path)]
|
||||
self._migrationops._pathutils.exists.assert_has_calls(expected)
|
||||
self._migrationops._pathutils.rmtree.assert_called_once_with(
|
||||
mock.sentinel.dest_path)
|
||||
self._migrationops._pathutils.rename.assert_called_once_with(
|
||||
move_folder_files = self._migrationops._pathutils.move_folder_files
|
||||
move_folder_files.assert_called_once_with(
|
||||
mock.sentinel.revert_path, mock.sentinel.instance_path)
|
||||
self._migrationops._pathutils.rmtree.assert_has_calls([
|
||||
mock.call(mock.sentinel.dest_path),
|
||||
mock.call(mock.sentinel.revert_path)])
|
||||
|
||||
def test_check_target_flavor(self):
|
||||
mock_instance = fake_instance.fake_instance_obj(self.context)
|
||||
|
@ -94,7 +94,8 @@ class MigrationOps(object):
|
||||
if dest_path and self._pathutils.exists(dest_path):
|
||||
self._pathutils.rmtree(dest_path)
|
||||
if self._pathutils.exists(revert_path):
|
||||
self._pathutils.rename(revert_path, instance_path)
|
||||
self._pathutils.move_folder_files(revert_path, instance_path)
|
||||
self._pathutils.rmtree(revert_path)
|
||||
except Exception as ex:
|
||||
# Log and ignore this exception
|
||||
LOG.exception(ex)
|
||||
|
Loading…
x
Reference in New Issue
Block a user