Replace use of handle_schedule_error() with set_vm_state_and_notify()
Conductor task build_instances() currently uses error handling code in scheduler driver to set instance error state and issue notifications. There is a similar method in scheduler utils that does the exact same, which a prior change converted to correctly send instance objects to notifications send_update(). This in additon has the added benefit of decoupling conductor from scheduler driver internals. Change-Id: Iad9ecf99734fb4c200ba046da42128299a1162f2 Related-Bug: #1396324
This commit is contained in:
@@ -45,7 +45,6 @@ from nova.objects import base as nova_object
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import quota
|
||||
from nova.scheduler import client as scheduler_client
|
||||
from nova.scheduler import driver as scheduler_driver
|
||||
from nova.scheduler import utils as scheduler_utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@@ -646,9 +645,9 @@ class ComputeTaskManager(base.Base):
|
||||
hosts = self.scheduler_client.select_destinations(context,
|
||||
request_spec, filter_properties)
|
||||
except Exception as exc:
|
||||
for instance in instances:
|
||||
scheduler_driver.handle_schedule_error(context, exc,
|
||||
instance.uuid, request_spec)
|
||||
updates = {'vm_state': vm_states.ERROR, 'task_state': None}
|
||||
self._set_vm_state_and_notify(context, 'build_instances', updates,
|
||||
exc, request_spec)
|
||||
return
|
||||
|
||||
for (instance, host) in itertools.izip(instances, hosts):
|
||||
|
||||
@@ -1348,7 +1348,7 @@ class _BaseTaskTestCase(object):
|
||||
exception = exc.NoValidHost(reason='fake-reason')
|
||||
self.mox.StubOutWithMock(scheduler_utils, 'build_request_spec')
|
||||
self.mox.StubOutWithMock(scheduler_utils, 'setup_instance_group')
|
||||
self.mox.StubOutWithMock(scheduler_driver, 'handle_schedule_error')
|
||||
self.mox.StubOutWithMock(scheduler_utils, 'set_vm_state_and_notify')
|
||||
self.mox.StubOutWithMock(self.conductor_manager.scheduler_client,
|
||||
'select_destinations')
|
||||
|
||||
@@ -1359,9 +1359,10 @@ class _BaseTaskTestCase(object):
|
||||
self.context, spec,
|
||||
{'retry': {'num_attempts': 1,
|
||||
'hosts': []}}).AndRaise(exception)
|
||||
for instance in instances:
|
||||
scheduler_driver.handle_schedule_error(self.context, exception,
|
||||
instance.uuid, spec)
|
||||
updates = {'vm_state': vm_states.ERROR, 'task_state': None}
|
||||
scheduler_utils.set_vm_state_and_notify(
|
||||
self.context, 'compute_task', 'build_instances', updates,
|
||||
exception, spec, self.conductor_manager.db)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
# build_instances() is a cast, we need to wait for it to complete
|
||||
|
||||
Reference in New Issue
Block a user