Merge "Remove system_metadata loading in Instance._load_flavor"

This commit is contained in:
Zuul
2017-10-16 12:25:53 +00:00
committed by Gerrit Code Review
3 changed files with 6 additions and 18 deletions
+2 -11
View File
@@ -776,11 +776,8 @@ class Instance(base.NovaPersistentObject, base.NovaObject,
# NOTE(alaski): We need to pull system_metadata for the
# notification.send_update() below. If we don't there's a KeyError
# when it tries to extract the flavor.
# NOTE(danms): If we have sysmeta, we need flavor since the caller
# might be expecting flavor information as a result
if 'system_metadata' not in expected_attrs:
expected_attrs.append('system_metadata')
expected_attrs.append('flavor')
old_ref, inst_ref = db.instance_update_and_get_original(
context, self.uuid, updates,
columns_to_join=_expected_cols(expected_attrs))
@@ -888,7 +885,7 @@ class Instance(base.NovaPersistentObject, base.NovaObject,
def _load_flavor(self):
instance = self.__class__.get_by_uuid(
self._context, uuid=self.uuid,
expected_attrs=['flavor', 'system_metadata'])
expected_attrs=['flavor'])
# NOTE(danms): Orphan the instance to make sure we don't lazy-load
# anything below
@@ -897,12 +894,6 @@ class Instance(base.NovaPersistentObject, base.NovaObject,
self.old_flavor = instance.old_flavor
self.new_flavor = instance.new_flavor
# NOTE(danms): The query above may have migrated the flavor from
# system_metadata. Since we have it anyway, go ahead and refresh
# our system_metadata from it so that a save will be accurate.
instance.system_metadata.update(self.get('system_metadata', {}))
self.system_metadata = instance.system_metadata
def _load_vcpu_model(self, db_vcpu_model=_NO_DATA_SENTINEL):
if db_vcpu_model is None:
self.vcpu_model = None
@@ -1100,7 +1091,7 @@ class Instance(base.NovaPersistentObject, base.NovaObject,
return getattr(self, attr)
except exception.FlavorNotFound:
# NOTE(danms): This only happens in the case where we don't
# have flavor information in sysmeta or extra, and doing
# have flavor information in instance_extra, and doing
# this triggers a lookup based on our instance_type_id for
# (very) legacy instances. That legacy code expects a None here,
# so emulate it for this helper, even though the actual attribute
+1 -3
View File
@@ -3000,9 +3000,7 @@ class ComputeTestCase(BaseTestCase,
{'task_state': task_pending,
'expected_task_state': expected_tasks,
'power_state': fake_power_state1},
columns_to_join=['system_metadata',
'extra',
'extra.flavor']),
columns_to_join=['system_metadata']),
mock.call(econtext, updated_dbinstance1['uuid'],
{'task_state': task_started,
'expected_task_state': task_pending},
+3 -4
View File
@@ -453,7 +453,7 @@ class _TestInstanceObject(object):
mock_db_instance_update_and_get_original.assert_called_once_with(
self.context, fake_uuid, expected_updates,
columns_to_join=['info_cache', 'security_groups',
'system_metadata', 'extra', 'extra.flavor']
'system_metadata']
)
if cell_type == 'api':
mock_cells_rpcapi_CellsAPI.return_value.instance_update_from_api \
@@ -523,7 +523,7 @@ class _TestInstanceObject(object):
columns_to_join=['info_cache', 'security_groups'])
mock_update_and_get.assert_called_once_with(self.context, fake_uuid,
expected_updates, columns_to_join=['info_cache', 'security_groups',
'system_metadata', 'extra', 'extra.flavor'])
'system_metadata'])
mock_send.assert_called_once_with(self.context, mock.ANY, mock.ANY)
@mock.patch('nova.db.instance_extra_update_by_uuid')
@@ -732,8 +732,7 @@ class _TestInstanceObject(object):
mock.call(self.context, inst.uuid,
{'vm_state': 'foo', 'task_state': 'bar',
'cell_name': 'foo!bar@baz'},
columns_to_join=['tags', 'system_metadata',
'extra', 'extra.flavor']),
columns_to_join=['tags', 'system_metadata']),
mock.call(self.context, inst.uuid,
{'vm_state': 'bar', 'task_state': 'foo'},
columns_to_join=['system_metadata', 'tags'])]