From 2adf6b8eed4eae912724169360a7a118126ed8a7 Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Sun, 22 Sep 2019 01:56:08 +0000 Subject: [PATCH] Handle GET /containers/ 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 --- zun/api/controllers/v1/containers.py | 4 ++-- zun/common/exception.py | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/zun/api/controllers/v1/containers.py b/zun/api/controllers/v1/containers.py index 65b7bba0c..02aebf621 100644 --- a/zun/api/controllers/v1/containers.py +++ b/zun/api/controllers/v1/containers.py @@ -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) diff --git a/zun/common/exception.py b/zun/common/exception.py index 5ce8efe38..847d92722 100644 --- a/zun/common/exception.py +++ b/zun/common/exception.py @@ -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