Avoid lazy-loading instance.flavor in cold migration
The instance.flavor is lazy-loaded currently in the resize method in nova/compute/api.py. Set expected_attrs=['flavor'] at the common.get_instance in the _migrate method in nova/api/openstack/compute/migrate_server.py to avid lazy-loading instance.flavor. Change-Id: Iba3b7c3e027ec78395a102c1fed46fa7a2ffa7be Closes-Bug: #1829877
This commit is contained in:
parent
1459e8edb9
commit
8f78dc68d9
nova
api/openstack/compute
tests/unit/api/openstack/compute
@ -52,7 +52,8 @@ class MigrateServerController(wsgi.Controller):
|
||||
body['migrate'] is not None):
|
||||
host_name = body['migrate'].get('host')
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id)
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
expected_attrs=['flavor'])
|
||||
|
||||
# We could potentially move this check to conductor and avoid the
|
||||
# extra API call to neutron when we support move operations with ports
|
||||
|
@ -51,6 +51,8 @@ class CommonMixin(object):
|
||||
expected_attrs = None
|
||||
if action == '_migrate_live':
|
||||
expected_attrs = ['numa_topology']
|
||||
elif action == '_migrate':
|
||||
expected_attrs = ['flavor']
|
||||
|
||||
uuid = uuidutils.generate_uuid()
|
||||
self.mock_get.side_effect = exception.InstanceNotFound(
|
||||
@ -72,6 +74,8 @@ class CommonMixin(object):
|
||||
expected_attrs = None
|
||||
if action == '_migrate_live':
|
||||
expected_attrs = ['numa_topology']
|
||||
elif action == '_migrate':
|
||||
expected_attrs = ['flavor']
|
||||
|
||||
if method is None:
|
||||
method = action.replace('_', '')
|
||||
@ -134,6 +138,8 @@ class CommonMixin(object):
|
||||
expected_attrs = None
|
||||
if action == '_migrate_live':
|
||||
expected_attrs = ['numa_topology']
|
||||
elif action == '_migrate':
|
||||
expected_attrs = ['flavor']
|
||||
|
||||
if method is None:
|
||||
method = action.replace('_', '')
|
||||
@ -173,6 +179,8 @@ class CommonMixin(object):
|
||||
expected_attrs = None
|
||||
if action == '_migrate_live':
|
||||
expected_attrs = ['numa_topology']
|
||||
elif action == '_migrate':
|
||||
expected_attrs = ['flavor']
|
||||
|
||||
if method is None:
|
||||
method = action.replace('_', '')
|
||||
|
@ -132,7 +132,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
||||
mock_resize.assert_called_once_with(
|
||||
self.context, instance, host_name=self.host_name)
|
||||
self.mock_get.assert_called_once_with(self.context, instance.uuid,
|
||||
expected_attrs=None,
|
||||
expected_attrs=['flavor'],
|
||||
cell_down_support=False)
|
||||
|
||||
def test_migrate_too_many_instances(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user