Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions nova/compute/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2270,6 +2270,10 @@ def create(
msg = _('The requested availability zone is not available')
raise exception.InvalidRequest(msg)

if scheduler_hints:
scheduler_hints = {k: v for k, v in scheduler_hints.items()
if not k.startswith('_nova')}

filter_properties = scheduler_utils.build_filter_properties(
scheduler_hints, forced_host, forced_node, flavor)

Expand Down
18 changes: 18 additions & 0 deletions nova/tests/unit/compute/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,24 @@ def _obj_to_list_obj(self, list_obj, obj):
list_obj.obj_reset_changes()
return list_obj

@mock.patch('nova.scheduler.utils.build_filter_properties')
def test_create_strips_internal_scheduler_hints(self,
mock_build_filter):
mock_build_filter.side_effect = (
test.TestingException('stop early'))
flavor = self._create_flavor()
self.assertRaises(
test.TestingException,
self.compute_api.create,
self.context, flavor, 'image_id',
scheduler_hints={
'_nova_check_type': 'rebuild',
'_nova_future': 'something',
'group': 'valid-group-uuid',
})
actual_hints = mock_build_filter.call_args[0][0]
self.assertEqual({'group': 'valid-group-uuid'}, actual_hints)

@mock.patch(
'nova.network.neutron.API.is_remote_managed_port',
new=mock.Mock(return_value=False),
Expand Down