[openstack-dev] [nova] [placement] small wart in the resource class API

Chris Dent cdent+os at anticdent.org
Thu Mar 16 13:12:42 UTC 2017


(This message is a question asking "should we fix this?" and "if so,
I guess that needs spec, since it is a microversion change, but
would an update to the existing spec be good enough?")

We have a small wart in the API for creating and updating resources
classes [1] that only became clear while evaluating the API for
resource traits [2]. The interface for creating a resource class is
not particularly idempotent and as a result the code for doing so
from nova-compute [3] is not as simple as it could be.

It's all in the name _get_of_create_resource_class. There is at
least one but sometimes two HTTP requests: first a GET to
/resource_classes/{class} then a POST with a body to
/resource_classes.

If instead there was just a straight PUT to
/resource_classes/{class} with no body that returned success either
upon create or "yeah it's already there" then it would always be one
request and the above code could be simplified. This is how we've
ended up defining things for traits [2].

Making this change would also allow us to address the fact that
right now the PUT to /resource_classes/{class} takes a body which is
the _new_ name with which to replace the name of the resource class
identified by {class}.  This is an operation I'm pretty sure we
don't want to do (commonly) as it means that anywhere that custom
resource class was used in an inventory it's now going to have this
new name (the relationship at the HTTP and outer layers is by name,
but at the database level by id, the PUT does a row update) but the
outside world is not savvy to this change.

Thoughts?

[1] http://specs.openstack.org/openstack/nova-specs/specs/ocata/approved/custom-resource-classes.html#rest-api-impact
[2] http://specs.openstack.org/openstack/nova-specs/specs/pike/approved/resource-provider-traits.html#rest-api-impact
[3] https://github.com/openstack/nova/blob/d02c0aa7ba0e37fb61d9fe2b683835f28f528623/nova/scheduler/client/report.py#L704

-- 
Chris Dent                 ¯\_(ツ)_/¯           https://anticdent.org/
freenode: cdent                                         tw: @anticdent


More information about the OpenStack-dev mailing list