Browse Source

Merge "Join migration_context and flavor in Migration.instance" into stable/rocky

changes/55/704255/1
Zuul 1 month ago
parent
commit
86067192b0
3 changed files with 11 additions and 6 deletions
  1. +2
    -1
      nova/objects/migration.py
  2. +4
    -1
      nova/tests/unit/compute/test_resource_tracker.py
  3. +5
    -4
      nova/tests/unit/objects/test_migration.py

+ 2
- 1
nova/objects/migration.py View File

@@ -169,7 +169,8 @@ class Migration(base.NovaPersistentObject, base.NovaObject,
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

+ 4
- 1
nova/tests/unit/compute/test_resource_tracker.py View File

@@ -2660,7 +2660,10 @@ class TestUpdateUsageFromMigrations(BaseTestCase):
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.'

+ 5
- 4
nova/tests/unit/objects/test_migration.py View File

@@ -161,10 +161,11 @@ class _TestMigrationObject(object):
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)

Loading…
Cancel
Save