[openstack-dev] Support for multiple sort keys and sort directions in REST GET APIs

Duncan Thomas duncan.thomas at gmail.com
Thu Apr 3 10:18:47 UTC 2014


Some of the cinder APIs do weird database joins and double lookups and
things, making every field sortable might have some serious database
performance impact and open up a DoS attack. Will need more
investigation to be sure.

On 2 April 2014 19:42, Steven Kaufer <kaufer at us.ibm.com> wrote:
> I have proposed blueprints in both nova and cinder for supporting multiple
> sort keys and sort directions for the GET APIs (servers and volumes).  I am
> trying to get feedback from other projects in order to have a more uniform
> API across services.
>
> Problem description from nova proposal:
>
> "There is no support for retrieving server data in a specific order, it is
> defaulted to descending sort order by the "created date" and "id" keys. In
> order to retrieve data in any sort order and direction, the REST APIs need
> to accept multiple sort keys and directions.
>
> Use Case: A UI that displays a table with only the page of data that it has
> retrieved from the server. The items in this table need to be sorted by
> status first and by display name second. In order to retrieve data in this
> order, the APIs must accept multiple sort keys/directions."
>
> See nova proposal .rst file (cinder is basically the same) for more
> information:  https://review.openstack.org/#/c/84451/
>
> Most projects have similar GET requests and I am trying to get some
> consensus on this approach across the various projects; the goal is to have
> this type of functionality common across projects (not just nova and
> cinder).  Note that some projects (ie, cinder) already support a single sort
> key and sort direction, see
> https://github.com/openstack/cinder/blob/master/cinder/api/v2/volumes.py#L212-L213
>
> Note that the DB layer already accepts multiple sort keys and sort
> directions (see
> https://github.com/openstack/oslo-incubator/blob/master/openstack/common/db/sqlalchemy/utils.py#L62),
> the work I am describing here only exposes the sorting options at the REST
> API layer.
>
> Please provide feedback on this direction.  Specifically, do you see any
> issues (and, if so, why) with allowing the caller to specify sort orders and
> directions on the GET APIs?
>
> Feel free to leave your feedback in the Gerrit review for the nova blueprint
> or reply to this thread.
>
> Thanks,
>
> Steven Kaufer
>
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>



-- 
Duncan Thomas



More information about the OpenStack-dev mailing list