← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1450167] [NEW] get_pagination_params's behaviour contradicts docstring

 

Public bug reported:

get_pagination_params's [1] docstring states that "If 'limit' is not
specified, 0, or > max_limit, we default to max_limit." In practice, the
code only sets params['limit'] if 'limit' is present in the GET request.
It appears as though get_pagination_params should be a private method,
and get_limit_and_marker [2] should be used instead.

An effect of this mixup can be observed by setting osapi_max_limit to 1
and listing images and flavors.

Images calls get_pagination_params directly [3]. The call ignores
osapi_max_limit=1 and returns all the images [attachment].

Flavors calls get_limit_and_marker [4]. The call correctly returns a
single flavor with a link to the following one [attachment].

[1] https://github.com/openstack/nova/blob/master/nova/api/openstack/common.py#L196
[2] https://github.com/openstack/nova/blob/master/nova/api/openstack/common.py#L273
[3] https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/images.py#L119
[4] https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/plugins/v3/flavors.py#L81

** Affects: nova
     Importance: Undecided
         Status: New

** Attachment added: "list-images-vs-list-flavors-with-osapi_max_limit=1.txt"
   https://bugs.launchpad.net/bugs/1450167/+attachment/4387773/+files/list-images-vs-list-flavors-with-osapi_max_limit%3D1.txt

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1450167

Title:
  get_pagination_params's behaviour contradicts docstring

Status in OpenStack Compute (Nova):
  New

Bug description:
  get_pagination_params's [1] docstring states that "If 'limit' is not
  specified, 0, or > max_limit, we default to max_limit." In practice,
  the code only sets params['limit'] if 'limit' is present in the GET
  request. It appears as though get_pagination_params should be a
  private method, and get_limit_and_marker [2] should be used instead.

  An effect of this mixup can be observed by setting osapi_max_limit to
  1 and listing images and flavors.

  Images calls get_pagination_params directly [3]. The call ignores
  osapi_max_limit=1 and returns all the images [attachment].

  Flavors calls get_limit_and_marker [4]. The call correctly returns a
  single flavor with a link to the following one [attachment].

  [1] https://github.com/openstack/nova/blob/master/nova/api/openstack/common.py#L196
  [2] https://github.com/openstack/nova/blob/master/nova/api/openstack/common.py#L273
  [3] https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/images.py#L119
  [4] https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/plugins/v3/flavors.py#L81

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1450167/+subscriptions


Follow ups

References