Hypervisors collection_name affects pagination query

Bug #1864428 reported by Fan Zhang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Fan Zhang
Rocky
Fix Released
Undecided
Unassigned
Stein
Fix Released
Undecided
Unassigned
Train
Fix Released
Undecided
Unassigned
OpenStack SDK
New
Undecided
Unassigned

Bug Description

In nova, hypervisor view builder's collect_name is 'hypervisors':

```
# nova.api.openstack.compute.views.hypervisors.ViewBuilder
class ViewBuilder(common.ViewBuilder):
    _collection_name = "hypervisors"

    def get_links(self, request, hypervisors, detail=False):
        coll_name = (self._collection_name + '/detail' if detail else
                     self._collection_name)
        return self._get_collection_links(request, hypervisors, coll_name,
                                          'id')
```

So when we do paginated query via openstacksdk, we would get response like this:

```
{u'hypervisors': [{u'status': u'enabled', u'state': u'up', u'id': u'53fb5bdc-f9a4-4fc4-a4be-8eb33cd236b1', u'hypervisor_hostname': u'gd02-compute-11e115e64e19'}, {u'status': u'enabled', u'state': u'up', u'id': u'a4db6ea8-2a91-45e7-a4b4-cb26c2dbc514', u'hypervisor_hostname': u'gd02-compute-11e115e64e11'}, {u'status': u'enabled', u'state': u'up', u'id': u'd92c5452-ea75-4f58-8e0b-b4a6823850d8', u'hypervisor_hostname': u'gd02-compute-11e115e64e12'}], u'hypervisors_links': [{u'href': u'http://nova-api.cty.os:11010/v2.1/hypervisors?limit=3&marker=d92c5452-ea75-4f58-8e0b-b4a6823850d8', u'rel': u'next'}]}
```

And openstacksdk uses wrong hypervisors_links to query next page, and get error:

```
Traceback (most recent call last):
  File "p_hypervisors-admin.py", line 48, in <module>
    do_operation(limit, marker)
  File "p_hypervisors-admin.py", line 38, in do_operation
    srvs = [i for i in info]
  File "/usr/lib/python2.7/site-packages/openstack/resource.py", line 898, in list
    exceptions.raise_from_response(response)
  File "/usr/lib/python2.7/site-packages/openstack/exceptions.py", line 212, in raise_from_response
    http_status=http_status, request_id=request_id
openstack.exceptions.NotFoundException: NotFoundException: 404: Client Error for url: http://nova-api.cty.os:11010/v2.1/hypervisors?limit=3&marker=ea9d857a-6328-47a8-abde-dc38972f4ca2, Not Found
```

The right uri should be `/v2.1/os-hypervisors`

Fan Zhang (fanzhang)
Changed in nova:
assignee: nobody → Fan Zhang (fanzhang)
summary: - Hypervisors collection_name effects pagination query
+ Hypervisors collection_name affects pagination query
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.opendev.org/709431

Changed in nova:
status: New → In Progress
Changed in nova:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/train)

Fix proposed to branch: stable/train
Review: https://review.opendev.org/711664

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/stein)

Fix proposed to branch: stable/stein
Review: https://review.opendev.org/711669

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/rocky)

Fix proposed to branch: stable/rocky
Review: https://review.opendev.org/711670

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

Reviewed: https://review.opendev.org/709431
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=b68033ecc9d38dcbe339c993338bdca691f73b33
Submitter: Zuul
Branch: master

commit b68033ecc9d38dcbe339c993338bdca691f73b33
Author: Fan Zhang <email address hidden>
Date: Mon Feb 24 16:49:35 2020 +0800

    Fix hypervisors paginted collection_name.

    Hypervisor view builder's _collection_name,
    'hypervisors' is used to build next link that
    sdk use as uri to do paginated query. But correct
    API should be `GET /v2.1/os-hypervisors?<params>`
    rather than `GET /v2.1/hypervisors?<params>`.

    This patch fixes this bug.

    Change-Id: Idc4f3fe54136a6bd3dbc7dc0efd3f62745991199
    Closes-Bug: 1864428
    Signed-off-by: Fan Zhang <email address hidden>

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/train)

Reviewed: https://review.opendev.org/711664
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=2f4e3ac3b018128b11a80ec343b333c3a6e4703f
Submitter: Zuul
Branch: stable/train

commit 2f4e3ac3b018128b11a80ec343b333c3a6e4703f
Author: Fan Zhang <email address hidden>
Date: Mon Feb 24 16:49:35 2020 +0800

    Fix hypervisors paginted collection_name.

    Hypervisor view builder's _collection_name,
    'hypervisors' is used to build next link that
    sdk use as uri to do paginated query. But correct
    API should be `GET /v2.1/os-hypervisors?<params>`
    rather than `GET /v2.1/hypervisors?<params>`.

    This patch fixes this bug.

    Change-Id: Idc4f3fe54136a6bd3dbc7dc0efd3f62745991199
    Closes-Bug: 1864428
    Signed-off-by: Fan Zhang <email address hidden>
    (cherry picked from commit b68033ecc9d38dcbe339c993338bdca691f73b33)

tags: added: in-stable-train
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/stein)

Reviewed: https://review.opendev.org/711669
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=9030b8a56d46eeef3e2a0ee6e19c3b05a277c77c
Submitter: Zuul
Branch: stable/stein

commit 9030b8a56d46eeef3e2a0ee6e19c3b05a277c77c
Author: Fan Zhang <email address hidden>
Date: Mon Feb 24 16:49:35 2020 +0800

    Fix hypervisors paginted collection_name.

    Hypervisor view builder's _collection_name,
    'hypervisors' is used to build next link that
    sdk use as uri to do paginated query. But correct
    API should be `GET /v2.1/os-hypervisors?<params>`
    rather than `GET /v2.1/hypervisors?<params>`.

    This patch fixes this bug.

    Change-Id: Idc4f3fe54136a6bd3dbc7dc0efd3f62745991199
    Closes-Bug: 1864428
    Signed-off-by: Fan Zhang <email address hidden>
    (cherry picked from commit b68033ecc9d38dcbe339c993338bdca691f73b33)
    (cherry picked from commit 2f4e3ac3b018128b11a80ec343b333c3a6e4703f)

tags: added: in-stable-stein
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/rocky)

Reviewed: https://review.opendev.org/711670
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=e50aecda86ecbd955aaab7e3b37f0d81836be579
Submitter: Zuul
Branch: stable/rocky

commit e50aecda86ecbd955aaab7e3b37f0d81836be579
Author: Fan Zhang <email address hidden>
Date: Mon Feb 24 16:49:35 2020 +0800

    Fix hypervisors paginted collection_name.

    Hypervisor view builder's _collection_name,
    'hypervisors' is used to build next link that
    sdk use as uri to do paginated query. But correct
    API should be `GET /v2.1/os-hypervisors?<params>`
    rather than `GET /v2.1/hypervisors?<params>`.

    This patch fixes this bug.

    Change-Id: Idc4f3fe54136a6bd3dbc7dc0efd3f62745991199
    Closes-Bug: 1864428
    Signed-off-by: Fan Zhang <email address hidden>
    (cherry picked from commit b68033ecc9d38dcbe339c993338bdca691f73b33)
    (cherry picked from commit 2f4e3ac3b018128b11a80ec343b333c3a6e4703f)
    (cherry picked from commit 9030b8a56d46eeef3e2a0ee6e19c3b05a277c77c)

tags: added: in-stable-rocky
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova rocky-eol

This issue was fixed in the openstack/nova rocky-eol release.

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.