List api for segments and hosts should return 400 error for invalid sort_key

Bug #1630530 reported by Dinesh Bhor
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
masakari
Fix Released
Undecided
Dinesh Bhor

Bug Description

If you pass invalid sort_key parameter to the list api of failover segments and hosts, then it returns 500 error.

Steps to reproduce:

failover_segments:

Command:

openstack@ubuntu:/opt/stack/masakari$ curl -g -i -X GET http://172.16.82.171:15868/v1/segments?sort_key=sdfsdf -H "Accept: application/json" -H "Content-Type: application/json" -H "X-Auth-Token: a1b05d1551f6419f8da564fa5b0c6a21"
HTTP/1.1 500 Internal Server Error
Openstack-Api-Version: masakari 1.0
Vary: OpenStack-API-Version
Content-Type: application/json; charset=UTF-8
Content-Length: 216
X-Openstack-Request-Id: req-af5c8a9f-6300-4063-a002-ce16b8b22f2b
Date: Mon, 03 Oct 2016 19:53:15 GMT

{"masakariFault": {"message": "Unexpected API Error. Please report this at http://bugs.launchpad.net/masakari/ and attach the Masakari API log if possible.\n<class 'masakari.exception.InvalidSortKey'>", "code": 500}}

hosts:

Command:

openstack@ubuntu:/opt/stack/masakari$ curl -g -i -X GET http://172.16.82.171:15868/v1/segments/56893e58-1e11-4893-8fa2-b82963da2834/hosts?sort_key=dsfsfs -H "Accept: application/json" -H "Content-Type: application/json" -H "X-Auth-Token: a1b05d1551f6419f8da564fa5b0c6a21"
HTTP/1.1 500 Internal Server Error
Openstack-Api-Version: masakari 1.0
Vary: OpenStack-API-Version
Content-Type: application/json; charset=UTF-8
Content-Length: 216
X-Openstack-Request-Id: req-dcf07691-4f65-485e-aa82-9d4614b1068b
Date: Mon, 03 Oct 2016 19:58:11 GMT

{"masakariFault": {"message": "Unexpected API Error. Please report this at http://bugs.launchpad.net/masakari/ and attach the Masakari API log if possible.\n<class 'masakari.exception.InvalidSortKey'>", "code": 500}}

Changed in masakari:
assignee: nobody → Dinesh Bhor (dinesh-bhor)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to masakari (master)

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

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

Reviewed: https://review.openstack.org/382280
Committed: https://git.openstack.org/cgit/openstack/masakari/commit/?id=77dd1ea0bdedff4ce10c4c238643962a677aa63b
Submitter: Jenkins
Branch: master

commit 77dd1ea0bdedff4ce10c4c238643962a677aa63b
Author: dineshbhor <email address hidden>
Date: Mon Oct 3 20:12:52 2016 +0530

    Fix 500 if you pass invalid sort_key and sort_dir

    Host and failover segments list apis return 500 InternalServerError if
    you pass invalid sort_key or sort_dir.

    Caught exception.InvalidSortKey at controller level and also allowed
    multiple sort_keys and sort_dirs to pass.

    NOTE:
    Allowed to pass multiple sort keys to list apis.
    Also moved the processing of request parameters from masakari/ha/api.py
    to respective failover segments and hosts controllers as request parameters
    should be handled in controller itself.

    Closes-Bug: #1630530
    Change-Id: Ib9d0faf5ca737a020099d5bac2b2ca0b03aa353e

Changed in masakari:
status: In Progress → Fix Released
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.