Use uuids in services and os-hypervisors APIs

Registered by Matt Riedemann

We currently leak database id fields (primary keys) out of the compute REST API for services and compute_nodes which are all in a cell database (the 'nova' database in a cells v2 deployment). These are in the os-services and os-hypervisors APIs, respectively.

For example, to delete a service record, you must issue a DELETE request to /os-services/{service_id} to delete the service record with that id.

The os-hypervisors API exposes the id in GET (index) requests and uses it in the "show" and "uptime" methods to look up the ComputeNode object by that id.

This is gross but functional in a single-cell deployment. However, in a multi-cell deployment, we have no context on which cell we should query to get service/node details from, since you could have multiple cells each with a nova-compute service and compute node with id 1, so which cell do you pick to delete the service or show details about the hypervisor?

This blueprint proposes to add a microversion to the compute REST API which replaces the usage of the id field with a uuid field. The uuid would be returned instead of the id in GET responses and also taken as input for the id in CRUD APIs.

Then when a request to delete a service is made, if the uuid is provided we can simply iterate cells until we find the service, or error with a 404.

Before the microversion, if an id is passed and there is only one cell, or no duplicates in multiple cells, we'll continue to honor the request. But if an id is passed on the request (before the microversion) and we cannot uniquely identify the record out of multiple cells, we error with a 400. This is similar behavior to how creating a server works when a network or port is not provided and there are multiple networks available to the project, we fail with a 400 "NetworkAmbiguous" error.

The compute_nodes table already has a uuid field. The services table, however, does not, so as part of this blueprint we'll need to add a uuid column to that table and corresponding versioned object.

Blueprint information

Status:
Complete
Approver:
Sean Dague
Priority:
Medium
Drafter:
Matt Riedemann
Direction:
Approved
Assignee:
Matt Riedemann
Definition:
Approved
Series goal:
Accepted for pike
Implementation:
Implemented
Milestone target:
milestone icon pike-3
Started by
Matt Riedemann
Completed by
Matt Riedemann

Whiteboard

LGTM (dansmith 8-Mar-2017)

I'm going to remove os-pci from this blueprint since that API isn't even exposed:

http://lists.openstack.org/pipermail/openstack-dev/2017-March/114261.html

-- mriedem 20170317

Gerrit topic: https://review.openstack.org/#q,topic:bp/service-hyper-uuid-in-api,n,z

Addressed by: https://review.openstack.org/447149
    Use uuids in services and os-hypervisors APIs (spec)

Addressed by: https://review.openstack.org/453025
    Add uuid to Service model

Addressed by: https://review.openstack.org/454899
    Add online data migration for populating services.uuid

Addressed by: https://review.openstack.org/461428
    db api: add get_service_by_uuid

Addressed by: https://review.openstack.org/461429
    objects: add Service.get_by_uuid method

Addressed by: https://review.openstack.org/461447
    db api: add compute_node_get_by_uuid method

Addressed by: https://review.openstack.org/461448
    objects: add ComputeNode.get_by_uuid method

Addressed by: https://review.openstack.org/461473
    Add uuid to service.update notification payload

Addressed by: https://review.openstack.org/461519
    Handle uuid in HostAPI._find_service

Addressed by: https://review.openstack.org/461532
    Handle uuid in HostAPI.compute_node_get

Gerrit topic: https://review.openstack.org/#q,topic:bp/service-hyper-uuid-in-ap,n,z

Addressed by: https://review.openstack.org/464280
    Use uuid for id in Services API

Addressed by: https://review.openstack.org/471899
    WIP: Handle uuids in os-hypervisors API

Addressed by: https://review.openstack.org/474381
    Centralize compute_node_search_by_hypervisor in os-hypervisors

Addressed by: https://review.openstack.org/474382
    Stop caching compute nodes in the request

Addressed by: https://review.openstack.org/475458
    Consolidate index and detail methods in HypervisorsController

Addressed by: https://review.openstack.org/476625
    Support paging over compute nodes with a uuid marker

Addressed by: https://review.openstack.org/484955
    api-ref: fix description of service_disable_reason

REST API changes are done for this blueprint with microversion 2.53. Now just need to complete the python-novaclient changes. -- mriedem 20170719

The python-novaclient support for microversion 2.53 is merged now so I'm going to mark this complete. -- mriedem 20170726

(?)

Work Items

Dependency tree

* Blueprints in grey have been implemented.

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.