Merge "Fix regression when listing build_requests with marker and ip filter" into stable/queens
This commit is contained in:
commit
a1842e6755
|
@ -2436,7 +2436,9 @@ class API(base.Base):
|
|||
skip_build_request = False
|
||||
orig_limit = limit
|
||||
if filter_ip:
|
||||
skip_build_request = True
|
||||
# We cannot skip build requests if there is a marker since the
|
||||
# the marker could be a build request.
|
||||
skip_build_request = marker is None
|
||||
if self.network_api.has_substr_port_filtering_extension(context):
|
||||
# We're going to filter by IP using Neutron so set filter_ip
|
||||
# to False so we don't attempt post-DB query filtering in
|
||||
|
|
|
@ -319,6 +319,35 @@ class ServersPreSchedulingTestCase(test.TestCase,
|
|||
# should have removed them.
|
||||
self.assertNotIn(volume_id, cinder.attachments[server['id']])
|
||||
|
||||
def test_instance_list_build_request_marker_ip_filter(self):
|
||||
"""Tests listing instances with a marker that is in the build_requests
|
||||
table and also filtering by ip, in which case the ip filter can't
|
||||
possibly find anything because instances that are not yet scheduled
|
||||
can't have ips, but the point is to find the marker in the build
|
||||
requests table.
|
||||
"""
|
||||
self.useFixture(nova_fixtures.AllServicesCurrent())
|
||||
# Create the server.
|
||||
body = {
|
||||
'server': {
|
||||
'name': 'test_instance_list_build_request_marker_ip_filter',
|
||||
'imageRef': fake_image.get_valid_image_id(),
|
||||
'flavorRef': '1',
|
||||
'networks': 'none'
|
||||
}
|
||||
}
|
||||
server = self.api.post_server(body)
|
||||
# Now list servers using the one we just created as the marker and
|
||||
# include the ip filter (see bug 1764685).
|
||||
search_opts = {
|
||||
'marker': server['id'],
|
||||
'ip': '192.168.159.150'
|
||||
}
|
||||
servers = self.api.get_servers(search_opts=search_opts)
|
||||
# We'll get 0 servers back because there are none with the specified
|
||||
# ip filter.
|
||||
self.assertEqual(0, len(servers))
|
||||
|
||||
|
||||
class EnforceVolumeBackedForZeroDiskFlavorTestCase(
|
||||
test.TestCase, integrated_helpers.InstanceHelperMixin):
|
||||
|
|
|
@ -5870,7 +5870,7 @@ class ComputeAPIUnitTestCase(_ComputeAPIUnitTestMixIn, test.NoDBTestCase):
|
|||
|
||||
self.compute_api.get_all(
|
||||
self.context, search_opts={'ip': 'fake'},
|
||||
limit=None, marker='fake-marker', sort_keys=['baz'],
|
||||
limit=None, marker=None, sort_keys=['baz'],
|
||||
sort_dirs=['desc'])
|
||||
|
||||
mock_list_port.assert_called_once_with(
|
||||
|
@ -5879,7 +5879,7 @@ class ComputeAPIUnitTestCase(_ComputeAPIUnitTestMixIn, test.NoDBTestCase):
|
|||
fields = ['metadata', 'info_cache', 'security_groups']
|
||||
mock_inst_get.assert_called_once_with(
|
||||
self.context, {'ip': 'fake', 'uuid': ['fake_device_id']},
|
||||
None, 'fake-marker', fields, ['baz'], ['desc'])
|
||||
None, None, fields, ['baz'], ['desc'])
|
||||
|
||||
@mock.patch.object(neutron_api.API, 'has_substr_port_filtering_extension')
|
||||
@mock.patch.object(neutron_api.API, 'list_ports')
|
||||
|
@ -5898,7 +5898,7 @@ class ComputeAPIUnitTestCase(_ComputeAPIUnitTestMixIn, test.NoDBTestCase):
|
|||
|
||||
self.compute_api.get_all(
|
||||
self.context, search_opts={'ip6': 'fake'},
|
||||
limit=None, marker='fake-marker', sort_keys=['baz'],
|
||||
limit=None, marker=None, sort_keys=['baz'],
|
||||
sort_dirs=['desc'])
|
||||
|
||||
mock_list_port.assert_called_once_with(
|
||||
|
@ -5907,7 +5907,7 @@ class ComputeAPIUnitTestCase(_ComputeAPIUnitTestMixIn, test.NoDBTestCase):
|
|||
fields = ['metadata', 'info_cache', 'security_groups']
|
||||
mock_inst_get.assert_called_once_with(
|
||||
self.context, {'ip6': 'fake', 'uuid': ['fake_device_id']},
|
||||
None, 'fake-marker', fields, ['baz'], ['desc'])
|
||||
None, None, fields, ['baz'], ['desc'])
|
||||
|
||||
@mock.patch.object(neutron_api.API, 'has_substr_port_filtering_extension')
|
||||
@mock.patch.object(neutron_api.API, 'list_ports')
|
||||
|
@ -5927,7 +5927,7 @@ class ComputeAPIUnitTestCase(_ComputeAPIUnitTestMixIn, test.NoDBTestCase):
|
|||
|
||||
self.compute_api.get_all(
|
||||
self.context, search_opts={'ip': 'fake1', 'ip6': 'fake2'},
|
||||
limit=None, marker='fake-marker', sort_keys=['baz'],
|
||||
limit=None, marker=None, sort_keys=['baz'],
|
||||
sort_dirs=['desc'])
|
||||
|
||||
mock_list_port.assert_has_calls([
|
||||
|
@ -5942,7 +5942,7 @@ class ComputeAPIUnitTestCase(_ComputeAPIUnitTestMixIn, test.NoDBTestCase):
|
|||
mock_inst_get.assert_called_once_with(
|
||||
self.context, {'ip': 'fake1', 'ip6': 'fake2',
|
||||
'uuid': ['fake_device_id', 'fake_device_id']},
|
||||
None, 'fake-marker', fields, ['baz'], ['desc'])
|
||||
None, None, fields, ['baz'], ['desc'])
|
||||
|
||||
@mock.patch.object(neutron_api.API, 'has_substr_port_filtering_extension')
|
||||
@mock.patch.object(neutron_api.API, 'list_ports')
|
||||
|
|
Loading…
Reference in New Issue