Only run placement request filters when Placement will be called
Any enabled placement request filters are processed during scheduling here: https://github.com/openstack/nova/blob/d78055/nova/scheduler/manager.py#L127 But then if we're doing a rebuild, or the driver.USES_ALLOCATION_CANDIDATES is False, we don't call placement: https://github.com/openstack/nova/blob/d78055/nova/scheduler/manager.py#L132 https://github.com/openstack/nova/blob/d78055/nova/scheduler/manager.py#L135 So we're unnecessarily processing the request spec filters (like querying the aggregates table) in those conditions. Change-Id: I8ed019c2208c28bb733aac961e855ce77f332a1e Closes-bug: #1772523
This commit is contained in:
parent
f902e0d5d8
commit
036fb56ab3
|
@ -123,16 +123,18 @@ class SchedulerManager(manager.Manager):
|
|||
request_spec,
|
||||
filter_properties)
|
||||
|
||||
try:
|
||||
request_filter.process_reqspec(ctxt, spec_obj)
|
||||
except exception.RequestFilterFailed as e:
|
||||
raise exception.NoValidHost(reason=e.message)
|
||||
|
||||
resources = utils.resources_from_request_spec(spec_obj)
|
||||
is_rebuild = utils.request_is_rebuild(spec_obj)
|
||||
alloc_reqs_by_rp_uuid, provider_summaries, allocation_request_version \
|
||||
= None, None, None
|
||||
if self.driver.USES_ALLOCATION_CANDIDATES and not is_rebuild:
|
||||
# Only process the Placement request spec filters when Placement
|
||||
# is used.
|
||||
try:
|
||||
request_filter.process_reqspec(ctxt, spec_obj)
|
||||
except exception.RequestFilterFailed as e:
|
||||
raise exception.NoValidHost(reason=e.message)
|
||||
|
||||
resources = utils.resources_from_request_spec(spec_obj)
|
||||
res = self.placement_client.get_allocation_candidates(ctxt,
|
||||
resources)
|
||||
if res is None:
|
||||
|
|
|
@ -227,10 +227,12 @@ class SchedulerManagerTestCase(test.NoDBTestCase):
|
|||
place_res = ([], {}, None)
|
||||
self._test_select_destination(place_res)
|
||||
|
||||
@mock.patch('nova.scheduler.request_filter.process_reqspec')
|
||||
@mock.patch('nova.scheduler.utils.resources_from_request_spec')
|
||||
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
|
||||
'get_allocation_candidates')
|
||||
def test_select_destination_is_rebuild(self, mock_get_ac, mock_rfrs):
|
||||
def test_select_destination_is_rebuild(self, mock_get_ac, mock_rfrs,
|
||||
mock_process):
|
||||
fake_spec = objects.RequestSpec(
|
||||
scheduler_hints={'_nova_check_type': ['rebuild']})
|
||||
fake_spec.instance_uuid = uuids.instance
|
||||
|
@ -242,6 +244,7 @@ class SchedulerManagerTestCase(test.NoDBTestCase):
|
|||
self.context, fake_spec,
|
||||
[fake_spec.instance_uuid], None, None, None, False)
|
||||
mock_get_ac.assert_not_called()
|
||||
mock_process.assert_not_called()
|
||||
|
||||
@mock.patch('nova.scheduler.utils.resources_from_request_spec')
|
||||
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
|
||||
|
|
Loading…
Reference in New Issue