Exclude build request marker from server listing
When listing "real" (already in cell) instances e.g. from nova_cell1.instances table, a marker option means "start after the instance with marker". For VMs: | uuid | name | | 1 | vm1 | | 2 | vm2 | "openstack server list --marker 1" returns vm2 only. But for VMs from nova_api.build_requests table it's different. For VMs: | uuid | name | | 1 | vm1 | | 2 | vm2 | "openstack server list --marker 1" returns both vm1 and vm2. This patch excludes instance with marker from listing for instances from build_requests table. Closes-Bug: #1808286 Change-Id: I5165b69f956fbf1904112a742698b2739f747e72
This commit is contained in:
parent
7fa740491e
commit
2ef704cba6
@ -445,7 +445,10 @@ class BuildRequestList(base.ObjectListBase, base.NovaObject):
|
|||||||
if marker:
|
if marker:
|
||||||
for i, build_req in enumerate(sorted_build_reqs):
|
for i, build_req in enumerate(sorted_build_reqs):
|
||||||
if build_req.instance.uuid == marker:
|
if build_req.instance.uuid == marker:
|
||||||
marker_index = i
|
# The marker is the last seen item in the last page, so
|
||||||
|
# we increment the index to the next item immediately
|
||||||
|
# after the marker so the marker is not returned.
|
||||||
|
marker_index = i + 1
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise exception.MarkerNotFound(marker=marker)
|
raise exception.MarkerNotFound(marker=marker)
|
||||||
|
@ -520,11 +520,14 @@ class BuildRequestListTestCase(test.NoDBTestCase):
|
|||||||
sort_dirs=['asc'])
|
sort_dirs=['asc'])
|
||||||
|
|
||||||
self.assertIsInstance(req_list, objects.BuildRequestList)
|
self.assertIsInstance(req_list, objects.BuildRequestList)
|
||||||
self.assertEqual(2, len(req_list))
|
self.assertEqual(1, len(req_list))
|
||||||
for i, req in enumerate(reqs[1:]):
|
req = req_list[0]
|
||||||
self.assertEqual(req.instance_uuid, req_list[i].instance_uuid)
|
expected_req = reqs[2]
|
||||||
objects.base.obj_equal_prims(req.instance,
|
# The returned build request should be the last one in the reqs list
|
||||||
req_list[i].instance)
|
# since the marker is the 2nd item in the list (of 3).
|
||||||
|
self.assertEqual(expected_req.instance_uuid, req.instance_uuid)
|
||||||
|
objects.base.obj_equal_prims(expected_req.instance,
|
||||||
|
req.instance)
|
||||||
|
|
||||||
def test_get_by_filters_marker_not_found(self):
|
def test_get_by_filters_marker_not_found(self):
|
||||||
self._create_req()
|
self._create_req()
|
||||||
@ -565,7 +568,7 @@ class BuildRequestListTestCase(test.NoDBTestCase):
|
|||||||
|
|
||||||
self.assertIsInstance(req_list, objects.BuildRequestList)
|
self.assertIsInstance(req_list, objects.BuildRequestList)
|
||||||
self.assertEqual(2, len(req_list))
|
self.assertEqual(2, len(req_list))
|
||||||
for i, req in enumerate(reqs[1:3]):
|
for i, req in enumerate(reqs[2:]):
|
||||||
self.assertEqual(req.instance_uuid, req_list[i].instance_uuid)
|
self.assertEqual(req.instance_uuid, req_list[i].instance_uuid)
|
||||||
objects.base.obj_equal_prims(req.instance,
|
objects.base.obj_equal_prims(req.instance,
|
||||||
req_list[i].instance)
|
req_list[i].instance)
|
||||||
@ -585,8 +588,8 @@ class BuildRequestListTestCase(test.NoDBTestCase):
|
|||||||
sort_keys=['id'], sort_dirs=['asc'])
|
sort_keys=['id'], sort_dirs=['asc'])
|
||||||
|
|
||||||
self.assertIsInstance(req_list, objects.BuildRequestList)
|
self.assertIsInstance(req_list, objects.BuildRequestList)
|
||||||
self.assertEqual(3, len(req_list))
|
self.assertEqual(2, len(req_list))
|
||||||
for i, req in enumerate(reqs[1:]):
|
for i, req in enumerate(reqs[2:]):
|
||||||
self.assertEqual(req.instance_uuid, req_list[i].instance_uuid)
|
self.assertEqual(req.instance_uuid, req_list[i].instance_uuid)
|
||||||
objects.base.obj_equal_prims(req.instance,
|
objects.base.obj_equal_prims(req.instance,
|
||||||
req_list[i].instance)
|
req_list[i].instance)
|
||||||
|
Loading…
Reference in New Issue
Block a user