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
(cherry picked from commit 7fb627c317
)
This commit is contained in:
parent
58c2f046b1
commit
7527a1f4d6
|
@ -97,8 +97,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.move_folder_files(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)
|
||||
|
|
|
@ -129,11 +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)
|
||||
mock_move_files = self._migrationops._pathutils.move_folder_files
|
||||
mock_move_files.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, root_gb, bdi):
|
||||
mock_instance = fake_instance.fake_instance_obj(self.context)
|
||||
|
|
Loading…
Reference in New Issue