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:
Matt Riedemann 2017-05-26 17:48:10 -04:00
parent fe0cf0fe04
commit dbaf80d2c9
3 changed files with 10 additions and 14 deletions

View File

@ -2555,6 +2555,9 @@ class API(base.Base):
cctxt, filters, limit=limit, marker=marker,
expected_attrs=expected_attrs, sort_keys=sort_keys,
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:
# We can ignore this since we need to look in the cell DB
cell0_instances = objects.InstanceList(objects=[])

View File

@ -14,7 +14,6 @@
from nova import test
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.unit import cast_as_call
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):
"""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
it shouldn't fail, it should just give the other two back. But due
to the bug we'll get a 400 since the marker isn't in cell1.
it shouldn't fail, it should just give the other two back.
"""
# create three test servers
for x in range(3):
@ -80,12 +78,7 @@ class ServerListLimitMarkerCell0Test(test.TestCase,
# Take the first server and user that as our marker.
marker = servers[0]['id']
# Since we're paging after the first server as our marker, there are
# only two left so specifying three should just return two. However,
# due to the bug, we're going to get a MarkerNotFound error when trying
# to page to the cell1 database and the marker isn't there. Assert
# we get two servers back once the bug is fixed.
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)
# only two left so specifying three should just return two.
servers = self.api.get_servers(search_opts=dict(marker=marker,
limit=3))
self.assertEqual(2, len(servers))

View File

@ -4696,7 +4696,7 @@ class _ComputeAPIUnitTestMixIn(object):
expected_attrs=None, sort_keys=['baz'],
sort_dirs=['desc']),
mock.call(mock.ANY, {'foo': 'bar'},
limit=8, marker='fake-marker',
limit=8, marker=None,
expected_attrs=None, sort_keys=['baz'],
sort_dirs=['desc'])
]
@ -4753,7 +4753,7 @@ class _ComputeAPIUnitTestMixIn(object):
expected_attrs=None, sort_keys=['baz'],
sort_dirs=['desc']),
mock.call(mock.ANY, {'foo': 'bar'},
limit=6, marker='fake-marker',
limit=6, marker=None,
expected_attrs=None, sort_keys=['baz'],
sort_dirs=['desc'])
]