Deprecate conductor's compute_stop() interface
We no longer need to run stop() actions through conductor to avoid the instance action database hit that compute_api.stop() would entail. This deprecates that interface and makes the manager use the compute_api method directly. Related to blueprint compute-api-objects Change-Id: I11ab8fadb3e417b5256504699603e8111ed69f7f
This commit is contained in:
parent
8a13967f12
commit
ca0883c88b
@ -4531,7 +4531,7 @@ class ComputeManager(manager.SchedulerDependentManager):
|
||||
# Note(maoy): here we call the API instead of
|
||||
# brutally updating the vm_state in the database
|
||||
# to allow all the hooks and checks to be performed.
|
||||
self.conductor_api.compute_stop(context, db_instance)
|
||||
self.compute_api.stop(context, db_instance)
|
||||
except Exception:
|
||||
# Note(maoy): there is no need to propagate the error
|
||||
# because the same power_state will be retrieved next
|
||||
@ -4544,7 +4544,7 @@ class ComputeManager(manager.SchedulerDependentManager):
|
||||
LOG.warn(_("Instance is suspended unexpectedly. Calling "
|
||||
"the stop API."), instance=db_instance)
|
||||
try:
|
||||
self.conductor_api.compute_stop(context, db_instance)
|
||||
self.compute_api.stop(context, db_instance)
|
||||
except Exception:
|
||||
LOG.exception(_("error during stop() in "
|
||||
"sync_power_state."),
|
||||
@ -4574,7 +4574,7 @@ class ComputeManager(manager.SchedulerDependentManager):
|
||||
try:
|
||||
# Note(maoy): this assumes that the stop API is
|
||||
# idempotent.
|
||||
self.conductor_api.compute_stop(context, db_instance)
|
||||
self.compute_api.stop(context, db_instance)
|
||||
except Exception:
|
||||
LOG.exception(_("error during stop() in "
|
||||
"sync_power_state."),
|
||||
|
@ -334,9 +334,6 @@ class LocalAPI(object):
|
||||
def get_ec2_ids(self, context, instance):
|
||||
return self._manager.get_ec2_ids(context, instance)
|
||||
|
||||
def compute_stop(self, context, instance, do_cast=True):
|
||||
return self._manager.compute_stop(context, instance, do_cast)
|
||||
|
||||
def compute_confirm_resize(self, context, instance, migration_ref):
|
||||
return self._manager.compute_confirm_resize(context, instance,
|
||||
migration_ref)
|
||||
|
@ -519,6 +519,8 @@ class ConductorManager(manager.Manager):
|
||||
|
||||
return ec2_ids
|
||||
|
||||
# NOTE(danms): This method is now deprecated and can be removed in
|
||||
# version v2.0 of the RPC API
|
||||
def compute_stop(self, context, instance, do_cast=True):
|
||||
# NOTE(mriedem): Clients using an interface before 1.43 will be sending
|
||||
# dicts so we need to handle that here since compute/api::stop()
|
||||
|
@ -479,16 +479,6 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
||||
msg = self.make_msg('get_ec2_ids', instance=instance_p)
|
||||
return self.call(context, msg, version='1.42')
|
||||
|
||||
def compute_stop(self, context, instance, do_cast=True):
|
||||
if not self.can_send_version('1.55'):
|
||||
instance = jsonutils.to_primitive(
|
||||
objects_base.obj_to_primitive(instance))
|
||||
version = '1.43'
|
||||
else:
|
||||
version = '1.55'
|
||||
msg = self.make_msg('compute_stop', instance=instance, do_cast=do_cast)
|
||||
return self.call(context, msg, version=version)
|
||||
|
||||
def compute_confirm_resize(self, context, instance, migration_ref):
|
||||
migration_p = jsonutils.to_primitive(migration_ref)
|
||||
if not self.can_send_version('1.52'):
|
||||
|
@ -498,9 +498,9 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
||||
instance = self._get_sync_instance(power_state, vm_state)
|
||||
instance.refresh()
|
||||
instance.save()
|
||||
self.mox.StubOutWithMock(self.compute.conductor_api, 'compute_stop')
|
||||
self.mox.StubOutWithMock(self.compute.compute_api, 'stop')
|
||||
if stop:
|
||||
self.compute.conductor_api.compute_stop(self.context, instance)
|
||||
self.compute.compute_api.stop(self.context, instance)
|
||||
self.mox.ReplayAll()
|
||||
self.compute._sync_instance_power_state(self.context, instance,
|
||||
driver_power_state)
|
||||
|
@ -594,12 +594,6 @@ class _BaseTestCase(object):
|
||||
result = self.conductor.get_ec2_ids(self.context, inst)
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
def test_compute_stop(self):
|
||||
self.mox.StubOutWithMock(self.conductor_manager.compute_api, 'stop')
|
||||
self.conductor_manager.compute_api.stop(self.context, 'instance', True)
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.compute_stop(self.context, 'instance')
|
||||
|
||||
def test_compute_confirm_resize(self):
|
||||
self.mox.StubOutWithMock(self.conductor_manager.compute_api,
|
||||
'confirm_resize')
|
||||
@ -819,16 +813,6 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
||||
self.conductor.security_groups_trigger_handler(self.context,
|
||||
'event', ['args'])
|
||||
|
||||
def test_compute_stop_with_objects(self):
|
||||
# use an instance object rather than a dict
|
||||
instance = self._create_fake_instance()
|
||||
inst_obj = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), instance)
|
||||
self.mox.StubOutWithMock(self.conductor_manager.compute_api, 'stop')
|
||||
self.conductor_manager.compute_api.stop(self.context, inst_obj, True)
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.compute_stop(self.context, inst_obj)
|
||||
|
||||
def test_compute_confirm_resize_with_objects(self):
|
||||
# use an instance object rather than a dict
|
||||
instance = self._create_fake_instance()
|
||||
|
Loading…
Reference in New Issue
Block a user