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:
Vishvananda Ishaya
2012-08-14 17:59:06 -07:00
parent 56b1b0087b
commit 2399008546
2 changed files with 6 additions and 17 deletions

View File

@@ -40,6 +40,7 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.3 - Remove instance_id, add instance to live_migration
1.4 - Remove update_db from prep_resize
1.5 - Add reservations argument to prep_resize()
1.6 - Remove reservations argument to run_instance()
'''
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,
injected_files, requested_networks, is_first_time,
filter_properties, reservations, call=True):
rpc_method = self.call if call else self.cast
return rpc_method(ctxt, self.make_msg('run_instance',
filter_properties):
return self.cast(ctxt, self.make_msg('run_instance',
request_spec=request_spec, admin_password=admin_password,
injected_files=injected_files,
requested_networks=requested_networks,
is_first_time=is_first_time,
filter_properties=filter_properties,
reservations=reservations), version='1.2')
filter_properties=filter_properties), version='1.6')
def prep_resize(self, ctxt, instance, instance_type, image,
request_spec, filter_properties, reservations):

View File

@@ -43,8 +43,6 @@ class SchedulerRpcAPITestCase(test.TestCase):
expected_version = kwargs.pop('version', rpcapi.BASE_RPC_API_VERSION)
expected_msg = rpcapi.make_msg(method, **kwargs)
expected_msg['version'] = expected_version
if rpc_method == 'cast' and method == 'run_instance':
kwargs['call'] = False
self.fake_args = None
self.fake_kwargs = None
@@ -64,21 +62,13 @@ class SchedulerRpcAPITestCase(test.TestCase):
for arg, expected_arg in zip(self.fake_args, expected_args):
self.assertEqual(arg, expected_arg)
def test_run_instance_call(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):
def test_run_instance(self):
self._test_scheduler_api('run_instance', rpc_method='cast',
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')
version='1.6')
def test_prep_resize(self):
self._test_scheduler_api('prep_resize', rpc_method='cast',