diff --git a/nova/objects/migration.py b/nova/objects/migration.py index 03ecfe36b64..6bdce7ee661 100644 --- a/nova/objects/migration.py +++ b/nova/objects/migration.py @@ -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 diff --git a/nova/tests/unit/compute/test_resource_tracker.py b/nova/tests/unit/compute/test_resource_tracker.py index 2ab2aac7a39..297513e3cc9 100644 --- a/nova/tests/unit/compute/test_resource_tracker.py +++ b/nova/tests/unit/compute/test_resource_tracker.py @@ -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.' diff --git a/nova/tests/unit/objects/test_migration.py b/nova/tests/unit/objects/test_migration.py index 16b7d2765e6..941c7ad853e 100644 --- a/nova/tests/unit/objects/test_migration.py +++ b/nova/tests/unit/objects/test_migration.py @@ -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)