Catch specific exception on claim

If resource claim fails, a ResourcesUnavailable exception will
be raised. We can catch this exception instead of catching a
generic exception.

Change-Id: I0bef394ac6c1c01a7b527d49ceb1613b90dcb480
This commit is contained in:
Hongbin Lu 2018-03-04 22:52:20 +00:00
parent 298b96234c
commit 0304d1b992
2 changed files with 2 additions and 4 deletions

View File

@ -79,7 +79,7 @@ class Claim(NopClaim):
self._pci_requests = pci_requests
# Check claim at constructor to avoid mess code
# Raise exception ComputeResourcesUnavailable if claim failed
# Raise exception ResourcesUnavailable if claim failed
self._claim_test(resources, limits)
@property

View File

@ -309,9 +309,7 @@ class Manager(periodic_task.PeriodicTasks):
context, container, requested_networks, requested_volumes,
sandbox, limits, reraise)
return created_container
except Exception as e:
# Other exception has handled in create sandbox and create base,
# exception occured here only can be the claim failed.
except exception.ResourcesUnavailable as e:
with excutils.save_and_reraise_exception(reraise=reraise):
LOG.exception("Container resource claim failed: %s",
six.text_type(e))