From 043200270cd867c7fac194375bd2a2cf16a5ba0c Mon Sep 17 00:00:00 2001 From: Sam Lucidi Date: Mon, 29 Jan 2018 14:51:31 -0500 Subject: [PATCH] Stop paging if page has less results than previous page --- .../openstack/legacy/openstack_handle/pagination/marker.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/manageiq/providers/openstack/legacy/openstack_handle/pagination/marker.rb b/lib/manageiq/providers/openstack/legacy/openstack_handle/pagination/marker.rb index 56affbf58..65656eecc 100644 --- a/lib/manageiq/providers/openstack/legacy/openstack_handle/pagination/marker.rb +++ b/lib/manageiq/providers/openstack/legacy/openstack_handle/pagination/marker.rb @@ -7,6 +7,7 @@ def list all_objects = objects_on_page = call_list_method(@collection_type, @options, @method) while more_pages?(objects_on_page) + last_page_count = objects_on_page.length objects_on_page = call_list_method(@collection_type, @options, @method, @@ -14,6 +15,10 @@ def list :limit => @service.default_pagination_limit) break if pagination_break?(all_objects, objects_on_page) all_objects.concat(objects_on_page) + # Break after adding this page if it contained less elements than the previous page. + # having less elements should indicate that this is the last page in the set. + # This is a sanity test to prevent timing-related looping or repetition + break if objects_on_page.length < last_page_count end all_objects