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
|
# Note(maoy): here we call the API instead of
|
||||||
# brutally updating the vm_state in the database
|
# brutally updating the vm_state in the database
|
||||||
# to allow all the hooks and checks to be performed.
|
# 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:
|
except Exception:
|
||||||
# Note(maoy): there is no need to propagate the error
|
# Note(maoy): there is no need to propagate the error
|
||||||
# because the same power_state will be retrieved next
|
# because the same power_state will be retrieved next
|
||||||
@ -4544,7 +4544,7 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||||||
LOG.warn(_("Instance is suspended unexpectedly. Calling "
|
LOG.warn(_("Instance is suspended unexpectedly. Calling "
|
||||||
"the stop API."), instance=db_instance)
|
"the stop API."), instance=db_instance)
|
||||||
try:
|
try:
|
||||||
self.conductor_api.compute_stop(context, db_instance)
|
self.compute_api.stop(context, db_instance)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception(_("error during stop() in "
|
LOG.exception(_("error during stop() in "
|
||||||
"sync_power_state."),
|
"sync_power_state."),
|
||||||
@ -4574,7 +4574,7 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||||||
try:
|
try:
|
||||||
# Note(maoy): this assumes that the stop API is
|
# Note(maoy): this assumes that the stop API is
|
||||||
# idempotent.
|
# idempotent.
|
||||||
self.conductor_api.compute_stop(context, db_instance)
|
self.compute_api.stop(context, db_instance)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception(_("error during stop() in "
|
LOG.exception(_("error during stop() in "
|
||||||
"sync_power_state."),
|
"sync_power_state."),
|
||||||
|
@ -334,9 +334,6 @@ class LocalAPI(object):
|
|||||||
def get_ec2_ids(self, context, instance):
|
def get_ec2_ids(self, context, instance):
|
||||||
return self._manager.get_ec2_ids(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):
|
def compute_confirm_resize(self, context, instance, migration_ref):
|
||||||
return self._manager.compute_confirm_resize(context, instance,
|
return self._manager.compute_confirm_resize(context, instance,
|
||||||
migration_ref)
|
migration_ref)
|
||||||
|
@ -519,6 +519,8 @@ class ConductorManager(manager.Manager):
|
|||||||
|
|
||||||
return ec2_ids
|
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):
|
def compute_stop(self, context, instance, do_cast=True):
|
||||||
# NOTE(mriedem): Clients using an interface before 1.43 will be sending
|
# NOTE(mriedem): Clients using an interface before 1.43 will be sending
|
||||||
# dicts so we need to handle that here since compute/api::stop()
|
# 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)
|
msg = self.make_msg('get_ec2_ids', instance=instance_p)
|
||||||
return self.call(context, msg, version='1.42')
|
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):
|
def compute_confirm_resize(self, context, instance, migration_ref):
|
||||||
migration_p = jsonutils.to_primitive(migration_ref)
|
migration_p = jsonutils.to_primitive(migration_ref)
|
||||||
if not self.can_send_version('1.52'):
|
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 = self._get_sync_instance(power_state, vm_state)
|
||||||
instance.refresh()
|
instance.refresh()
|
||||||
instance.save()
|
instance.save()
|
||||||
self.mox.StubOutWithMock(self.compute.conductor_api, 'compute_stop')
|
self.mox.StubOutWithMock(self.compute.compute_api, 'stop')
|
||||||
if stop:
|
if stop:
|
||||||
self.compute.conductor_api.compute_stop(self.context, instance)
|
self.compute.compute_api.stop(self.context, instance)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
self.compute._sync_instance_power_state(self.context, instance,
|
self.compute._sync_instance_power_state(self.context, instance,
|
||||||
driver_power_state)
|
driver_power_state)
|
||||||
|
@ -594,12 +594,6 @@ class _BaseTestCase(object):
|
|||||||
result = self.conductor.get_ec2_ids(self.context, inst)
|
result = self.conductor.get_ec2_ids(self.context, inst)
|
||||||
self.assertEqual(result, expected)
|
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):
|
def test_compute_confirm_resize(self):
|
||||||
self.mox.StubOutWithMock(self.conductor_manager.compute_api,
|
self.mox.StubOutWithMock(self.conductor_manager.compute_api,
|
||||||
'confirm_resize')
|
'confirm_resize')
|
||||||
@ -819,16 +813,6 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
|||||||
self.conductor.security_groups_trigger_handler(self.context,
|
self.conductor.security_groups_trigger_handler(self.context,
|
||||||
'event', ['args'])
|
'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):
|
def test_compute_confirm_resize_with_objects(self):
|
||||||
# use an instance object rather than a dict
|
# use an instance object rather than a dict
|
||||||
instance = self._create_fake_instance()
|
instance = self._create_fake_instance()
|
||||||
|
Loading…
Reference in New Issue
Block a user