Skip to content

Commit

Permalink
Merge "Join migration_context and flavor in Migration.instance" into …
Browse files Browse the repository at this point in the history
…stable/rocky
  • Loading branch information
Zuul authored and openstack-gerrit committed Jan 16, 2020
2 parents 619f1e6 + e48fb84 commit 8606719
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion nova/objects/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ def save(self):
def instance(self):
if not hasattr(self, '_cached_instance'):
self._cached_instance = objects.Instance.get_by_uuid(
self._context, self.instance_uuid)
self._context, self.instance_uuid,
expected_attrs=['migration_context', 'flavor'])
return self._cached_instance

@instance.setter
Expand Down
5 changes: 4 additions & 1 deletion nova/tests/unit/compute/test_resource_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2660,7 +2660,10 @@ def test_instance_not_found(self, mock_get_instance, mock_update_usage):
self.rt._update_usage_from_migrations(mock.sentinel.ctx, [migration],
_NODENAME)
mock_get_instance.assert_called_once_with(mock.sentinel.ctx,
'some_uuid')
'some_uuid',
expected_attrs=[
'migration_context',
'flavor'])
self.assertFalse(mock_update_usage.called)

@mock.patch('nova.compute.resource_tracker.ResourceTracker.'
Expand Down
9 changes: 5 additions & 4 deletions nova/tests/unit/objects/test_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,11 @@ def test_instance(self, mock_get):
fake_migration)
mig._context = ctxt
self.assertEqual(mig.instance.host, fake_inst['host'])
mock_get.assert_called_once_with(ctxt,
fake_migration['instance_uuid'],
columns_to_join=['info_cache',
'security_groups'])
mock_get.assert_called_once_with(
ctxt, fake_migration['instance_uuid'],
columns_to_join=['extra',
'extra.flavor',
'extra.migration_context'])

def test_instance_setter(self):
migration = objects.Migration(instance_uuid=uuidsentinel.instance)
Expand Down

0 comments on commit 8606719

Please # to comment.