Handle GET /containers/<UUID> when host is down

In before, we retrieved container details from host, thus having
to reject the request if the host is down. This commit avoid failing
the request even if the host is down, in which case we will retrieve
container details from DB.

Change-Id: Icd6870147eaf7b9a7004fbdfd29a7d18621bf0df
Closes-Bug: #1844120
This commit is contained in:
Hongbin Lu 2019-09-22 01:56:08 +00:00
parent 93984198a8
commit 2adf6b8eed
2 changed files with 2 additions and 7 deletions

View File

@ -234,8 +234,8 @@ class ContainersController(base.Controller):
compute_api = pecan.request.compute_api
try:
container = compute_api.container_show(context, container)
except exception.ContainerHostNotUp:
raise exception.ServerNotUsable
except exception.ContainerHostNotUp as e:
LOG.error("Failed to get container details: %s", str(e))
return view.format_container(context, pecan.request.host_url,
container)

View File

@ -713,11 +713,6 @@ class ContainerActionEventNotFound(ZunException):
message = _("Event %(event)s not found for action id %(action_id)s")
class ServerNotUsable(ZunException):
message = _("Zun server not usable")
code = 404
class OverQuota(ZunException):
message = _("Quota exceeded for resources: %(overs)s")
code = 403