Merge "Only query BDMs once in API during rebuild"

This commit is contained in:
Jenkins 2017-10-10 14:50:14 +00:00 committed by Gerrit Code Review
commit 1995b60c15
2 changed files with 5 additions and 4 deletions

View File

@ -2883,7 +2883,9 @@ class API(base.Base):
self._check_auto_disk_config(image=image, **kwargs) self._check_auto_disk_config(image=image, **kwargs)
flavor = instance.get_flavor() flavor = instance.get_flavor()
root_bdm = compute_utils.get_root_bdm(context, instance) bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance.uuid)
root_bdm = compute_utils.get_root_bdm(context, instance, bdms)
self._checks_for_create_and_rebuild(context, image_id, image, self._checks_for_create_and_rebuild(context, image_id, image,
flavor, metadata, files_to_inject, root_bdm) flavor, metadata, files_to_inject, root_bdm)
@ -2935,9 +2937,6 @@ class API(base.Base):
# system metadata... and copy in the properties for the new image. # system metadata... and copy in the properties for the new image.
orig_sys_metadata = _reset_image_metadata() orig_sys_metadata = _reset_image_metadata()
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
context, instance.uuid)
self._record_action_start(context, instance, instance_actions.REBUILD) self._record_action_start(context, instance, instance_actions.REBUILD)
# NOTE(sbauza): The migration script we provided in Newton should make # NOTE(sbauza): The migration script we provided in Newton should make

View File

@ -3157,6 +3157,8 @@ class _ComputeAPIUnitTestMixIn(object):
_checks_for_create_and_rebuild.assert_called_once_with(self.context, _checks_for_create_and_rebuild.assert_called_once_with(self.context,
None, image, flavor, {}, [], None) None, image, flavor, {}, [], None)
self.assertNotEqual(orig_system_metadata, instance.system_metadata) self.assertNotEqual(orig_system_metadata, instance.system_metadata)
bdm_get_by_instance_uuid.assert_called_once_with(
self.context, instance.uuid)
@mock.patch.object(objects.RequestSpec, 'get_by_instance_uuid') @mock.patch.object(objects.RequestSpec, 'get_by_instance_uuid')
@mock.patch.object(objects.Instance, 'save') @mock.patch.object(objects.Instance, 'save')