Only query BDMs once in API during rebuild
We were unnecessarily looking up BDMs from the database
more than once during rebuild in the API. This makes that
a single read.
Change-Id: Iab929210d11336d09d9eef14ff6904e630ba195a
(cherry picked from commit 718e5af486
)
This commit is contained in:
parent
c7991653a4
commit
6c1a0889bc
@ -2917,7 +2917,9 @@ class API(base.Base):
|
||||
self._check_auto_disk_config(image=image, **kwargs)
|
||||
|
||||
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,
|
||||
flavor, metadata, files_to_inject, root_bdm)
|
||||
|
||||
@ -2969,9 +2971,6 @@ class API(base.Base):
|
||||
# system metadata... and copy in the properties for the new image.
|
||||
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)
|
||||
|
||||
# NOTE(sbauza): The migration script we provided in Newton should make
|
||||
|
@ -3158,6 +3158,8 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||
_checks_for_create_and_rebuild.assert_called_once_with(self.context,
|
||||
None, image, flavor, {}, [], None)
|
||||
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, 'save')
|
||||
@mock.patch.object(objects.RequestSpec, 'get_by_instance_uuid')
|
||||
|
Loading…
Reference in New Issue
Block a user