Merge "compute: Don't delete the original attachment during pre LM rollback" into stable/train
This commit is contained in:
commit
a87bb740ef
|
@ -7760,7 +7760,12 @@ class ComputeManager(manager.Manager):
|
||||||
for bdm in bdms:
|
for bdm in bdms:
|
||||||
try:
|
try:
|
||||||
original_bdm = original_bdms_by_volid[bdm.volume_id]
|
original_bdm = original_bdms_by_volid[bdm.volume_id]
|
||||||
if bdm.attachment_id and original_bdm.attachment_id:
|
# NOTE(lyarwood): Only delete the referenced attachment if it
|
||||||
|
# is different to the original in order to avoid accidentally
|
||||||
|
# removing the source host volume attachment after it has
|
||||||
|
# already been rolled back by a failure in pre_live_migration.
|
||||||
|
if (bdm.attachment_id and original_bdm.attachment_id and
|
||||||
|
bdm.attachment_id != original_bdm.attachment_id):
|
||||||
# NOTE(lyarwood): 3.44 cinder api flow. Delete the
|
# NOTE(lyarwood): 3.44 cinder api flow. Delete the
|
||||||
# attachment used by the bdm and reset it to that of
|
# attachment used by the bdm and reset it to that of
|
||||||
# the original bdm.
|
# the original bdm.
|
||||||
|
|
|
@ -26,8 +26,8 @@ class TestVolAttachmentsDuringPreLiveMigration(
|
||||||
"""Regression test for bug 1889108.
|
"""Regression test for bug 1889108.
|
||||||
|
|
||||||
This regression test asserts that the original source volume attachments
|
This regression test asserts that the original source volume attachments
|
||||||
are incorrectly removed during the rollback from pre_live_migration
|
are not removed during the rollback from pre_live_migration failures on the
|
||||||
failures on the destination.
|
destination.
|
||||||
"""
|
"""
|
||||||
api_major_version = 'v2.1'
|
api_major_version = 'v2.1'
|
||||||
microversion = 'latest'
|
microversion = 'latest'
|
||||||
|
@ -105,9 +105,7 @@ class TestVolAttachmentsDuringPreLiveMigration(
|
||||||
server = self.api.get_server(server['id'])
|
server = self.api.get_server(server['id'])
|
||||||
self.assertEqual(src_host, server['OS-EXT-SRV-ATTR:host'])
|
self.assertEqual(src_host, server['OS-EXT-SRV-ATTR:host'])
|
||||||
|
|
||||||
# FIXME(lyarwood): Assert that both the src and dest attachments have
|
# Assert that the src attachment is still present
|
||||||
# been removed. Only the dest attachment should be removed during the
|
|
||||||
# rollback of a pre_live_migration failure.
|
|
||||||
attachments = self.cinder.volume_to_attachment.get(volume_id)
|
attachments = self.cinder.volume_to_attachment.get(volume_id)
|
||||||
self.assertNotIn(src_attachment_id, attachments.keys())
|
self.assertIn(src_attachment_id, attachments.keys())
|
||||||
self.assertEqual(0, len(attachments))
|
self.assertEqual(1, len(attachments))
|
||||||
|
|
|
@ -9523,6 +9523,19 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
|
||||||
self.assertIn('Exception while attempting to rollback',
|
self.assertIn('Exception while attempting to rollback',
|
||||||
mock_log.exception.call_args[0][0])
|
mock_log.exception.call_args[0][0])
|
||||||
|
|
||||||
|
@mock.patch('nova.volume.cinder.API.attachment_delete')
|
||||||
|
def test_rollback_volume_bdms_after_pre_failure(
|
||||||
|
self, mock_delete_attachment):
|
||||||
|
instance = fake_instance.fake_instance_obj(
|
||||||
|
self.context, uuid=uuids.instance)
|
||||||
|
original_bdms = bdms = self._generate_volume_bdm_list(instance)
|
||||||
|
self.compute._rollback_volume_bdms(
|
||||||
|
self.context, bdms, original_bdms, instance)
|
||||||
|
# Assert that attachment_delete isn't called when the bdms have already
|
||||||
|
# been rolled back by a failure in pre_live_migration to reference the
|
||||||
|
# source bdms.
|
||||||
|
mock_delete_attachment.assert_not_called()
|
||||||
|
|
||||||
@mock.patch.object(objects.ComputeNode,
|
@mock.patch.object(objects.ComputeNode,
|
||||||
'get_first_node_by_host_for_old_compat')
|
'get_first_node_by_host_for_old_compat')
|
||||||
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
|
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
|
||||||
|
|
Loading…
Reference in New Issue