-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: Normalize exception handling for os-hypervisors
Many of the functions implementing the various 'os-hypervisors' endpoints share common code. In particular any of these functions contain calls to both the 'instance_get_all_by_host' and 'service_get_by_compute_host' APIs of 'nova.compute.api.HostAPI' so we can include instance and service information in the responses. All of these calls are guarded with exception handlers, but the exceptions handled differ between resources. There is one exception we need to care about for 'instance_get_all_by_host': 'HostMappingNotFound', which is raised because the API is decorated with the 'target_cell' decorator. The 'service_get_by_compute_host' API is also decorated by the 'target_host_cell' decorator, however, it can also raise 'ComputeHostNotFound'. This exception is possible because the 'service_get_by_compute_host' API calls 'nova.objects.Service.get_by_compute_host', which in turns calls 'nova.db.sqlalchemy.api.service_get_by_compute_host', via the '_db_service_get_by_compute_host' helper. Not all of the functions that called 'service_get_by_compute_host' were correctly guarding against 'ComputeHostNotFound'. In addition to this, the call to the 'get_host_uptime' API used by the '/os-hypervisors/uptime' API can raise 'HostNotFound' if the service has been deleted but the compute node still has to be manually cleaned up. Conversely, a number of functions were handling 'ValueError' even though this couldn't realistically be raised by the test. Resolve all of the above. Change-Id: Iacabaea31311ae14084b55341608e16e531e6bd5 Signed-off-by: Stephen Finucane <[email protected]> Related-Bug: #1646255
- Loading branch information
1 parent
4689996
commit ef7598a
Showing
2 changed files
with
178 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters