Fix MarkerNotFound when paging and marker was found in cell0
If we're paging over cells and the marker was found in cell0, we need to null it out so we don't attempt to lookup by marker from any other cells if there is more room in the limit. Change-Id: I8a957bebfcecd6ac712103c346e028d80f1ecd7c Closes-Bug: #1689692
This commit is contained in:
parent
fe0cf0fe04
commit
dbaf80d2c9
@ -2555,6 +2555,9 @@ class API(base.Base):
|
|||||||
cctxt, filters, limit=limit, marker=marker,
|
cctxt, filters, limit=limit, marker=marker,
|
||||||
expected_attrs=expected_attrs, sort_keys=sort_keys,
|
expected_attrs=expected_attrs, sort_keys=sort_keys,
|
||||||
sort_dirs=sort_dirs)
|
sort_dirs=sort_dirs)
|
||||||
|
# If we found the marker in cell0 we need to set it to None
|
||||||
|
# so we don't expect to find it in the cells below.
|
||||||
|
marker = None
|
||||||
except exception.MarkerNotFound:
|
except exception.MarkerNotFound:
|
||||||
# We can ignore this since we need to look in the cell DB
|
# We can ignore this since we need to look in the cell DB
|
||||||
cell0_instances = objects.InstanceList(objects=[])
|
cell0_instances = objects.InstanceList(objects=[])
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
from nova import test
|
from nova import test
|
||||||
from nova.tests import fixtures as nova_fixtures
|
from nova.tests import fixtures as nova_fixtures
|
||||||
from nova.tests.functional.api import client as api_client
|
|
||||||
from nova.tests.functional import integrated_helpers
|
from nova.tests.functional import integrated_helpers
|
||||||
from nova.tests.unit import cast_as_call
|
from nova.tests.unit import cast_as_call
|
||||||
from nova.tests.unit.image import fake as image_fake
|
from nova.tests.unit.image import fake as image_fake
|
||||||
@ -62,8 +61,7 @@ class ServerListLimitMarkerCell0Test(test.TestCase,
|
|||||||
def test_list_servers_marker_in_cell0_more_limit(self):
|
def test_list_servers_marker_in_cell0_more_limit(self):
|
||||||
"""Creates three servers, then lists them with a marker on the first
|
"""Creates three servers, then lists them with a marker on the first
|
||||||
and a limit of 3 which is more than what's left to page on (2) but
|
and a limit of 3 which is more than what's left to page on (2) but
|
||||||
it shouldn't fail, it should just give the other two back. But due
|
it shouldn't fail, it should just give the other two back.
|
||||||
to the bug we'll get a 400 since the marker isn't in cell1.
|
|
||||||
"""
|
"""
|
||||||
# create three test servers
|
# create three test servers
|
||||||
for x in range(3):
|
for x in range(3):
|
||||||
@ -80,12 +78,7 @@ class ServerListLimitMarkerCell0Test(test.TestCase,
|
|||||||
# Take the first server and user that as our marker.
|
# Take the first server and user that as our marker.
|
||||||
marker = servers[0]['id']
|
marker = servers[0]['id']
|
||||||
# Since we're paging after the first server as our marker, there are
|
# Since we're paging after the first server as our marker, there are
|
||||||
# only two left so specifying three should just return two. However,
|
# only two left so specifying three should just return two.
|
||||||
# due to the bug, we're going to get a MarkerNotFound error when trying
|
servers = self.api.get_servers(search_opts=dict(marker=marker,
|
||||||
# to page to the cell1 database and the marker isn't there. Assert
|
limit=3))
|
||||||
# we get two servers back once the bug is fixed.
|
self.assertEqual(2, len(servers))
|
||||||
ex = self.assertRaises(api_client.OpenStackApiException,
|
|
||||||
self.api.get_servers,
|
|
||||||
search_opts=dict(marker=marker, limit=3))
|
|
||||||
self.assertEqual(400, ex.response.status_code)
|
|
||||||
self.assertIn('marker [%s] not found' % marker, ex.message)
|
|
||||||
|
@ -4696,7 +4696,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||||||
expected_attrs=None, sort_keys=['baz'],
|
expected_attrs=None, sort_keys=['baz'],
|
||||||
sort_dirs=['desc']),
|
sort_dirs=['desc']),
|
||||||
mock.call(mock.ANY, {'foo': 'bar'},
|
mock.call(mock.ANY, {'foo': 'bar'},
|
||||||
limit=8, marker='fake-marker',
|
limit=8, marker=None,
|
||||||
expected_attrs=None, sort_keys=['baz'],
|
expected_attrs=None, sort_keys=['baz'],
|
||||||
sort_dirs=['desc'])
|
sort_dirs=['desc'])
|
||||||
]
|
]
|
||||||
@ -4753,7 +4753,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||||||
expected_attrs=None, sort_keys=['baz'],
|
expected_attrs=None, sort_keys=['baz'],
|
||||||
sort_dirs=['desc']),
|
sort_dirs=['desc']),
|
||||||
mock.call(mock.ANY, {'foo': 'bar'},
|
mock.call(mock.ANY, {'foo': 'bar'},
|
||||||
limit=6, marker='fake-marker',
|
limit=6, marker=None,
|
||||||
expected_attrs=None, sort_keys=['baz'],
|
expected_attrs=None, sort_keys=['baz'],
|
||||||
sort_dirs=['desc'])
|
sort_dirs=['desc'])
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user