v1 images list call should use real pagination

Bug #1024614 reported by Brian Waldon
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance Client
Fix Released
Wishlist
Brian Waldon

Bug Description

The call to glanceclient.v1.ImageManager.list accepts a limit and marker, but that essentially offloads pagination to the end user. The client should be more helpful and implement real pagination itself.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-glanceclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/9816

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-glanceclient (master)

Reviewed: https://review.openstack.org/9816
Committed: http://github.com/openstack/python-glanceclient/commit/0f628b19cbbe53ea29de02f4ae84bc893138820f
Submitter: Jenkins
Branch: master

commit 0f628b19cbbe53ea29de02f4ae84bc893138820f
Author: Brian Waldon <email address hidden>
Date: Sat Jul 14 04:39:27 2012 +0000

    Add pagination to v1 image-list

    * Use recursive generator function to make subsequent requests
      to the v1 detailed images resource
    * 'limit' continues to act as the absolute limit of images to return
      from a list call
    * 'page_size' indicates how many images to ask for in each subsequent
      pagination request
    * Expose --page-size through the cli
    * Convert v1 images tests to use strict url comparison
    * Drop strict_url_check from FakeAPI kwargs - now the functionality
      is always active and tests must directly match fixture urls
    * Fix bug 1024614

    Change-Id: Ifa7874d88360e03b5c8aa95bfb9d5e6dc6dc927e

Changed in python-glanceclient:
status: In Progress → Fix Committed
Revision history for this message
Tihomir Trifonov (ttrifonov) wrote :

There is a minor problem here with using Horizon api.glance.image_list_detailed:

    def image_list_detailed(request, marker=None, filters=None):
        filters = filters or {}
        limit = getattr(settings, 'API_RESULT_LIMIT', 1000)
        page_size = getattr(settings, 'API_RESULT_PAGE_SIZE', 20)
        images = list(glanceclient(request).images.list(page_size=page_size,
                                                        limit=limit,
                                                        marker=marker,
                                                        filters=filters))

The 'marker' field is always passed, either when it is 'None' or an actual value. Then in /v1/images.py we have:

119 if 'marker' in kwargs:
120 params['marker'] = kwargs['marker']

and in case of marker=None, it is appended to

    url = '/v1/images/detail?%s' % urllib.urlencode(qp)

and it becomes '/v1/images/detail?marker=None&limit=20' which then raises an error in Glance. So it can be changed in Horizon glance.py, but I think it is better to be fixed in python-glanceclient with something like:

119 if 'marker' in kwargs and kwargs['marker']:
120 params['marker'] = kwargs['marker']

Revision history for this message
Tihomir Trifonov (ttrifonov) wrote :

Ah, another interesting thing - when page_size = 1, then it returns 3 images, instead of 2.. There might be a good reason for that though. I've just made a simple test - if adding this:

    and seen <= page_size

in the if in `def paginate()`, seems to return 1 for page_size=1, and works for page_size=2 and 20(I've tested only with these).

Revision history for this message
Tihomir Trifonov (ttrifonov) wrote :

For the first comment - I've just removed the 'None' values from the kwargs list in images.list() - https://review.openstack.org/#/c/10122/2/horizon/api/glance.py .

Revision history for this message
Brian Waldon (bcwaldon) wrote :

Released in v0.2.0

Changed in python-glanceclient:
status: Fix Committed → Fix Released
Brian Waldon (bcwaldon)
Changed in python-glanceclient:
milestone: v1.0 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.