Always create the run_instance records locally
Currently a request for multiple instances issent to the scheduler, where it is written to the database. It appears that this was done so that more advanced schedulers could handle the request as one batch, but the result is the scheduler is sometimes slow enough that the call will timeout. Instead this converts to always creating the instance records locally and making run_instance into a casting instead of a call. This made a small change to the rpc api for run instance, so the version was bumped. Legacy messages are still handled properly. Fixes bug 1036911 Co-authored-by: Chris Behrens <cbehrens@codestud.com> Change-Id: I63bbc98c285faebec53f8e62857c01548807db68
This commit is contained in:
@@ -40,6 +40,7 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
|||||||
1.3 - Remove instance_id, add instance to live_migration
|
1.3 - Remove instance_id, add instance to live_migration
|
||||||
1.4 - Remove update_db from prep_resize
|
1.4 - Remove update_db from prep_resize
|
||||||
1.5 - Add reservations argument to prep_resize()
|
1.5 - Add reservations argument to prep_resize()
|
||||||
|
1.6 - Remove reservations argument to run_instance()
|
||||||
'''
|
'''
|
||||||
|
|
||||||
BASE_RPC_API_VERSION = '1.0'
|
BASE_RPC_API_VERSION = '1.0'
|
||||||
@@ -50,15 +51,13 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
|||||||
|
|
||||||
def run_instance(self, ctxt, request_spec, admin_password,
|
def run_instance(self, ctxt, request_spec, admin_password,
|
||||||
injected_files, requested_networks, is_first_time,
|
injected_files, requested_networks, is_first_time,
|
||||||
filter_properties, reservations, call=True):
|
filter_properties):
|
||||||
rpc_method = self.call if call else self.cast
|
return self.cast(ctxt, self.make_msg('run_instance',
|
||||||
return rpc_method(ctxt, self.make_msg('run_instance',
|
|
||||||
request_spec=request_spec, admin_password=admin_password,
|
request_spec=request_spec, admin_password=admin_password,
|
||||||
injected_files=injected_files,
|
injected_files=injected_files,
|
||||||
requested_networks=requested_networks,
|
requested_networks=requested_networks,
|
||||||
is_first_time=is_first_time,
|
is_first_time=is_first_time,
|
||||||
filter_properties=filter_properties,
|
filter_properties=filter_properties), version='1.6')
|
||||||
reservations=reservations), version='1.2')
|
|
||||||
|
|
||||||
def prep_resize(self, ctxt, instance, instance_type, image,
|
def prep_resize(self, ctxt, instance, instance_type, image,
|
||||||
request_spec, filter_properties, reservations):
|
request_spec, filter_properties, reservations):
|
||||||
|
|||||||
@@ -43,8 +43,6 @@ class SchedulerRpcAPITestCase(test.TestCase):
|
|||||||
expected_version = kwargs.pop('version', rpcapi.BASE_RPC_API_VERSION)
|
expected_version = kwargs.pop('version', rpcapi.BASE_RPC_API_VERSION)
|
||||||
expected_msg = rpcapi.make_msg(method, **kwargs)
|
expected_msg = rpcapi.make_msg(method, **kwargs)
|
||||||
expected_msg['version'] = expected_version
|
expected_msg['version'] = expected_version
|
||||||
if rpc_method == 'cast' and method == 'run_instance':
|
|
||||||
kwargs['call'] = False
|
|
||||||
|
|
||||||
self.fake_args = None
|
self.fake_args = None
|
||||||
self.fake_kwargs = None
|
self.fake_kwargs = None
|
||||||
@@ -64,21 +62,13 @@ class SchedulerRpcAPITestCase(test.TestCase):
|
|||||||
for arg, expected_arg in zip(self.fake_args, expected_args):
|
for arg, expected_arg in zip(self.fake_args, expected_args):
|
||||||
self.assertEqual(arg, expected_arg)
|
self.assertEqual(arg, expected_arg)
|
||||||
|
|
||||||
def test_run_instance_call(self):
|
def test_run_instance(self):
|
||||||
self._test_scheduler_api('run_instance', rpc_method='call',
|
|
||||||
request_spec='fake_request_spec',
|
|
||||||
admin_password='pw', injected_files='fake_injected_files',
|
|
||||||
requested_networks='fake_requested_networks',
|
|
||||||
is_first_time=True, filter_properties='fake_filter_properties',
|
|
||||||
reservations=None, version='1.2')
|
|
||||||
|
|
||||||
def test_run_instance_cast(self):
|
|
||||||
self._test_scheduler_api('run_instance', rpc_method='cast',
|
self._test_scheduler_api('run_instance', rpc_method='cast',
|
||||||
request_spec='fake_request_spec',
|
request_spec='fake_request_spec',
|
||||||
admin_password='pw', injected_files='fake_injected_files',
|
admin_password='pw', injected_files='fake_injected_files',
|
||||||
requested_networks='fake_requested_networks',
|
requested_networks='fake_requested_networks',
|
||||||
is_first_time=True, filter_properties='fake_filter_properties',
|
is_first_time=True, filter_properties='fake_filter_properties',
|
||||||
reservations=None, version='1.2')
|
version='1.6')
|
||||||
|
|
||||||
def test_prep_resize(self):
|
def test_prep_resize(self):
|
||||||
self._test_scheduler_api('prep_resize', rpc_method='cast',
|
self._test_scheduler_api('prep_resize', rpc_method='cast',
|
||||||
|
|||||||
Reference in New Issue
Block a user