Merge "Move retry of prep_resize to conductor instead of scheduler"
This commit is contained in:
@@ -1450,7 +1450,7 @@ class ComputeManager(manager.Manager):
|
|||||||
return rescheduled
|
return rescheduled
|
||||||
|
|
||||||
def _reschedule(self, context, request_spec, filter_properties,
|
def _reschedule(self, context, request_spec, filter_properties,
|
||||||
instance, scheduler_method, method_args, task_state,
|
instance, reschedule_method, method_args, task_state,
|
||||||
exc_info=None):
|
exc_info=None):
|
||||||
"""Attempt to re-schedule a compute operation."""
|
"""Attempt to re-schedule a compute operation."""
|
||||||
|
|
||||||
@@ -1470,7 +1470,7 @@ class ComputeManager(manager.Manager):
|
|||||||
request_spec['instance_uuids'] = [instance_uuid]
|
request_spec['instance_uuids'] = [instance_uuid]
|
||||||
|
|
||||||
LOG.debug("Re-scheduling %(method)s: attempt %(num)d",
|
LOG.debug("Re-scheduling %(method)s: attempt %(num)d",
|
||||||
{'method': scheduler_method.func_name,
|
{'method': reschedule_method.func_name,
|
||||||
'num': retry['num_attempts']}, instance_uuid=instance_uuid)
|
'num': retry['num_attempts']}, instance_uuid=instance_uuid)
|
||||||
|
|
||||||
# reset the task state:
|
# reset the task state:
|
||||||
@@ -1481,7 +1481,7 @@ class ComputeManager(manager.Manager):
|
|||||||
retry['exc'] = traceback.format_exception_only(exc_info[0],
|
retry['exc'] = traceback.format_exception_only(exc_info[0],
|
||||||
exc_info[1])
|
exc_info[1])
|
||||||
|
|
||||||
scheduler_method(context, *method_args)
|
reschedule_method(context, *method_args)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@periodic_task.periodic_task
|
@periodic_task.periodic_task
|
||||||
@@ -3492,17 +3492,14 @@ class ComputeManager(manager.Manager):
|
|||||||
instance_uuid = instance['uuid']
|
instance_uuid = instance['uuid']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# NOTE(comstud): remove the scheduler RPCAPI method when
|
reschedule_method = self.compute_task_api.resize_instance
|
||||||
# this is adjusted to send to conductor... and then
|
scheduler_hint = dict(filter_properties=filter_properties)
|
||||||
# deprecate the scheduler manager method.
|
method_args = (instance, None, scheduler_hint, instance_type,
|
||||||
scheduler_method = self.scheduler_rpcapi.prep_resize
|
quotas.reservations)
|
||||||
instance_p = obj_base.obj_to_primitive(instance)
|
|
||||||
method_args = (instance_p, instance_type, image, request_spec,
|
|
||||||
filter_properties, quotas.reservations)
|
|
||||||
task_state = task_states.RESIZE_PREP
|
task_state = task_states.RESIZE_PREP
|
||||||
|
|
||||||
rescheduled = self._reschedule(context, request_spec,
|
rescheduled = self._reschedule(context, request_spec,
|
||||||
filter_properties, instance, scheduler_method,
|
filter_properties, instance, reschedule_method,
|
||||||
method_args, task_state, exc_info)
|
method_args, task_state, exc_info)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
rescheduled = False
|
rescheduled = False
|
||||||
|
@@ -150,6 +150,13 @@ class FakeSchedulerAPI(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FakeComputeTaskAPI(object):
|
||||||
|
|
||||||
|
def resize_instance(self, context, instance, extra_instance_updates,
|
||||||
|
scheduler_hint, flavor, reservations):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class BaseTestCase(test.TestCase):
|
class BaseTestCase(test.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@@ -231,7 +238,10 @@ class BaseTestCase(test.TestCase):
|
|||||||
self.stubs.Set(fake_image._FakeImageService, 'show', fake_show)
|
self.stubs.Set(fake_image._FakeImageService, 'show', fake_show)
|
||||||
|
|
||||||
fake_rpcapi = FakeSchedulerAPI()
|
fake_rpcapi = FakeSchedulerAPI()
|
||||||
|
fake_taskapi = FakeComputeTaskAPI()
|
||||||
self.stubs.Set(self.compute, 'scheduler_rpcapi', fake_rpcapi)
|
self.stubs.Set(self.compute, 'scheduler_rpcapi', fake_rpcapi)
|
||||||
|
self.stubs.Set(self.compute, 'compute_task_api', fake_taskapi)
|
||||||
|
|
||||||
fake_network.set_stub_network_methods(self.stubs)
|
fake_network.set_stub_network_methods(self.stubs)
|
||||||
fake_server_actions.stub_out_action_events(self.stubs)
|
fake_server_actions.stub_out_action_events(self.stubs)
|
||||||
|
|
||||||
@@ -10170,12 +10180,12 @@ class ComputeReschedulingResizeTestCase(ComputeReschedulingTestCase):
|
|||||||
instance = fake_instance.fake_db_instance(uuid=instance_uuid)
|
instance = fake_instance.fake_db_instance(uuid=instance_uuid)
|
||||||
instance = self._objectify(instance)
|
instance = self._objectify(instance)
|
||||||
instance_type = {}
|
instance_type = {}
|
||||||
image = None
|
|
||||||
reservations = None
|
reservations = None
|
||||||
|
|
||||||
scheduler_method = self.compute.scheduler_rpcapi.prep_resize
|
scheduler_method = self.compute.compute_task_api.resize_instance
|
||||||
method_args = (instance, instance_type, image, request_spec,
|
scheduler_hint = dict(filter_properties=filter_properties)
|
||||||
filter_properties, reservations)
|
method_args = (instance, None, scheduler_hint, instance_type,
|
||||||
|
reservations)
|
||||||
|
|
||||||
return self.compute._reschedule(self.context, request_spec,
|
return self.compute._reschedule(self.context, request_spec,
|
||||||
filter_properties, instance, scheduler_method,
|
filter_properties, instance, scheduler_method,
|
||||||
@@ -10462,13 +10472,14 @@ class ComputeRescheduleResizeOrReraiseTestCase(BaseTestCase):
|
|||||||
raises another exception
|
raises another exception
|
||||||
"""
|
"""
|
||||||
instance = self._create_fake_instance_obj()
|
instance = self._create_fake_instance_obj()
|
||||||
method_args = (None, instance, self.instance_type, None, None,
|
scheduler_hint = dict(filter_properties={})
|
||||||
None)
|
method_args = (instance, None, scheduler_hint, self.instance_type,
|
||||||
|
None)
|
||||||
self.mox.StubOutWithMock(self.compute, "_reschedule")
|
self.mox.StubOutWithMock(self.compute, "_reschedule")
|
||||||
|
|
||||||
self.compute._reschedule(
|
self.compute._reschedule(
|
||||||
self.context, None, None, instance,
|
self.context, None, None, instance,
|
||||||
self.compute.scheduler_rpcapi.prep_resize, method_args,
|
self.compute.compute_task_api.resize_instance, method_args,
|
||||||
task_states.RESIZE_PREP).AndRaise(
|
task_states.RESIZE_PREP).AndRaise(
|
||||||
InnerTestingException("Inner"))
|
InnerTestingException("Inner"))
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
@@ -10487,12 +10498,14 @@ class ComputeRescheduleResizeOrReraiseTestCase(BaseTestCase):
|
|||||||
rescheduled.
|
rescheduled.
|
||||||
"""
|
"""
|
||||||
instance = self._create_fake_instance_obj()
|
instance = self._create_fake_instance_obj()
|
||||||
method_args = (None, instance, self.instance_type, None, None, None)
|
scheduler_hint = dict(filter_properties={})
|
||||||
|
method_args = (instance, None, scheduler_hint, self.instance_type,
|
||||||
|
None)
|
||||||
self.mox.StubOutWithMock(self.compute, "_reschedule")
|
self.mox.StubOutWithMock(self.compute, "_reschedule")
|
||||||
|
|
||||||
self.compute._reschedule(
|
self.compute._reschedule(
|
||||||
self.context, None, None, instance,
|
self.context, None, None, instance,
|
||||||
self.compute.scheduler_rpcapi.prep_resize, method_args,
|
self.compute.compute_task_api.resize_instance, method_args,
|
||||||
task_states.RESIZE_PREP).AndReturn(False)
|
task_states.RESIZE_PREP).AndReturn(False)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
@@ -10508,8 +10521,10 @@ class ComputeRescheduleResizeOrReraiseTestCase(BaseTestCase):
|
|||||||
def test_reschedule_true(self):
|
def test_reschedule_true(self):
|
||||||
# If rescheduled, the original resize exception should be logged.
|
# If rescheduled, the original resize exception should be logged.
|
||||||
instance = self._create_fake_instance_obj()
|
instance = self._create_fake_instance_obj()
|
||||||
instance_p = obj_base.obj_to_primitive(instance)
|
scheduler_hint = dict(filter_properties={})
|
||||||
method_args = (instance_p, self.instance_type, None, {}, {}, None)
|
method_args = (instance, None, scheduler_hint, self.instance_type,
|
||||||
|
None)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
raise test.TestingException("Original")
|
raise test.TestingException("Original")
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -10519,7 +10534,7 @@ class ComputeRescheduleResizeOrReraiseTestCase(BaseTestCase):
|
|||||||
self.mox.StubOutWithMock(self.compute, "_log_original_error")
|
self.mox.StubOutWithMock(self.compute, "_log_original_error")
|
||||||
self.compute._reschedule(self.context, {}, {},
|
self.compute._reschedule(self.context, {}, {},
|
||||||
instance,
|
instance,
|
||||||
self.compute.scheduler_rpcapi.prep_resize, method_args,
|
self.compute.compute_task_api.resize_instance, method_args,
|
||||||
task_states.RESIZE_PREP, exc_info).AndReturn(True)
|
task_states.RESIZE_PREP, exc_info).AndReturn(True)
|
||||||
|
|
||||||
self.compute._log_original_error(exc_info, instance.uuid)
|
self.compute._log_original_error(exc_info, instance.uuid)
|
||||||
|
Reference in New Issue
Block a user