Segment ignore sorting parameters

Bug #1763161 reported by Hongbin Lu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Hongbin Lu

Bug Description

Send a request to get a list of network segments sorted by name but the response doesn't seem to be sorted (below is an example). Segment should support sorting to align with other API resources.

$ curl -g -s -X GET "http://10.0.0.15:9696/v2.0/segments?sort_dir=asc&sort_key=name" -H "Accept: application/json" -H "X-Auth-Token: $TOKEN" | jq .
{
  "segments": [
    {
      "name": null,
      "network_id": "02dd8479-ef26-4398-a102-d19d0a7b3a1f",
      "segmentation_id": 24,
      "network_type": "vxlan",
      "physical_network": null,
      "id": "0a046acf-594f-4488-80a5-89b01f4c0f7d",
      "description": null
    },
    {
      "name": "segment1",
      "network_id": "a650210a-6ad6-44fc-8a17-fee8829352ca",
      "segmentation_id": 55,
      "network_type": "vxlan",
      "physical_network": null,
      "id": "d0cc2af3-903b-4451-9d4a-8d7d8216fa16",
      "description": null
    },
    {
      "name": "segment2",
      "network_id": "a650210a-6ad6-44fc-8a17-fee8829352ca",
      "segmentation_id": 2016,
      "network_type": "vxlan",
      "physical_network": null,
      "id": "5a0e733b-bc40-4225-9dab-729338107d1a",
      "description": null
    },
    {
      "name": null,
      "network_id": "ad93b454-4836-46c7-bfc8-64a20a2ab95a",
      "segmentation_id": null,
      "network_type": "flat",
      "physical_network": "public",
      "id": "6131da02-f769-4b31-997d-cefa46c5198c",
      "description": null
    }
  ]
}

Hongbin Lu (hongbin.lu)
Changed in neutron:
assignee: nobody → Hongbin Lu (hongbin.lu)
Miguel Lavalle (minsel)
Changed in neutron:
status: New → Confirmed
Revision history for this message
Miguel Lavalle (minsel) wrote :

Tested and confirmed this bug with system built from master. Requesting sort by descending order:

$ curl -g -s -X GET "http://localhost:9696/v2.0/segments?sort_dir=desc&sort_key=name" -H "Content-type: application/json" -H "X-Auth-Token: $TOKEN" | jq
{
  "segments": [
    {
      "name": "segment1",
      "network_id": "8445c42e-d281-4fd0-8ff0-481f1356bc0b",
      "segmentation_id": 2016,
      "network_type": "vlan",
      "physical_network": "physnet1",
      "id": "44a4ff93-0ab5-4b94-b7ea-b0266d022f8d",
      "description": null
    },
    {
      "name": "segment2",
      "network_id": "8445c42e-d281-4fd0-8ff0-481f1356bc0b",
      "segmentation_id": 2016,
      "network_type": "vlan",
      "physical_network": "physnet2",
      "id": "ae421d4d-4b76-4e1a-bb70-f51c46386c2f",
      "description": null
    },
    {
      "name": null,
      "network_id": "96efc697-2aa9-4dbf-b1f5-22234f33cddf",
      "segmentation_id": 1021,
      "network_type": "vxlan",
      "physical_network": null,
      "id": "97258b18-0f90-4c97-90b9-15b25f320908",
      "description": null
    },
    {
      "name": null,
      "network_id": "ba67524e-c8fa-4d9e-b701-2b8cf67617e2",
      "segmentation_id": null,
      "network_type": "flat",
      "physical_network": "public",
      "id": "44a28675-60de-420c-8f3a-5653a7acdedc",
      "description": null
    }
  ]
}

Returns the same as ascending order:

$ curl -g -s -X GET "http://localhost:9696/v2.0/segments?sort_dir=asc&sort_key=name" -H "Content-type: application/json" -H "X-Auth-Token: $TOKEN" | jq
{
  "segments": [
    {
      "name": "segment1",
      "network_id": "8445c42e-d281-4fd0-8ff0-481f1356bc0b",
      "segmentation_id": 2016,
      "network_type": "vlan",
      "physical_network": "physnet1",
      "id": "44a4ff93-0ab5-4b94-b7ea-b0266d022f8d",
      "description": null
    },
    {
      "name": "segment2",
      "network_id": "8445c42e-d281-4fd0-8ff0-481f1356bc0b",
      "segmentation_id": 2016,
      "network_type": "vlan",
      "physical_network": "physnet2",
      "id": "ae421d4d-4b76-4e1a-bb70-f51c46386c2f",
      "description": null
    },
    {
      "name": null,
      "network_id": "96efc697-2aa9-4dbf-b1f5-22234f33cddf",
      "segmentation_id": 1021,
      "network_type": "vxlan",
      "physical_network": null,
      "id": "97258b18-0f90-4c97-90b9-15b25f320908",
      "description": null
    },
    {
      "name": null,
      "network_id": "ba67524e-c8fa-4d9e-b701-2b8cf67617e2",
      "segmentation_id": null,
      "network_type": "flat",
      "physical_network": "public",
      "id": "44a28675-60de-420c-8f3a-5653a7acdedc",
      "description": null
    }
  ]
}

While the sorting extension is enabled:

$ neutron ext-list | grep sorting
| sorting | Sorting support

Changed in neutron:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

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

Changed in neutron:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/561361
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=43d451d86f8c1f9dff2a8580089a631680bb0c09
Submitter: Zuul
Branch: master

commit 43d451d86f8c1f9dff2a8580089a631680bb0c09
Author: Hongbin Lu <email address hidden>
Date: Fri Apr 13 21:47:02 2018 +0000

    Enable sorting and pagination for segments

    It looks the sorting and pagination are natively supported in
    segment db layer but the segment controller doesn't mark these
    features as supported. This patch fixes it.

    Change-Id: I325396bb0256196ee6c6fc42cc812a0c75ae3827
    Closes-Bug: #1763161

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 13.0.0.0b2

This issue was fixed in the openstack/neutron 13.0.0.0b2 development milestone.

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.