From a0e05fd7d892f58d296e35a9185ff4f0b6ec5240 Mon Sep 17 00:00:00 2001 From: Volker Theile Date: Tue, 8 Jan 2019 15:24:59 +0100 Subject: [PATCH] mgr/dashboard: Improve exception handling in /api/rgw/status In some cases the exception message was not forwarded to the caller. Signed-off-by: Volker Theile --- src/pybind/mgr/dashboard/controllers/rgw.py | 23 ++++++++++--------- .../ceph/rgw/rgw-501/rgw-501.component.html | 2 +- .../mgr/dashboard/services/rgw_client.py | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/rgw.py b/src/pybind/mgr/dashboard/controllers/rgw.py index 83679d28ae8cd..871fa00fdf4ee 100644 --- a/src/pybind/mgr/dashboard/controllers/rgw.py +++ b/src/pybind/mgr/dashboard/controllers/rgw.py @@ -2,16 +2,17 @@ from __future__ import absolute_import import json + import cherrypy from . import ApiController, BaseController, RESTController, Endpoint, \ - ReadPermission + ReadPermission from .. import logger +from ..exceptions import DashboardException +from ..rest_client import RequestException from ..security import Scope from ..services.ceph_service import CephService from ..services.rgw_client import RgwClient -from ..rest_client import RequestException -from ..exceptions import DashboardException @ApiController('/rgw', Scope.RGW) @@ -25,21 +26,21 @@ class Rgw(BaseController): instance = RgwClient.admin_instance() # Check if the service is online. if not instance.is_service_online(): - status['message'] = 'Failed to connect to the Object Gateway\'s Admin Ops API.' - raise RequestException(status['message']) + msg = 'Failed to connect to the Object Gateway\'s Admin Ops API.' + raise RequestException(msg) # Ensure the API user ID is known by the RGW. if not instance.user_exists(): - status['message'] = 'The user "{}" is unknown to the Object Gateway.'.format( + msg = 'The user "{}" is unknown to the Object Gateway.'.format( instance.userid) - raise RequestException(status['message']) + raise RequestException(msg) # Ensure the system flag is set for the API user ID. if not instance.is_system_user(): - status['message'] = 'The system flag is not set for user "{}".'.format( + msg = 'The system flag is not set for user "{}".'.format( instance.userid) - raise RequestException(status['message']) + raise RequestException(msg) status['available'] = True - except (RequestException, LookupError): - pass + except (RequestException, LookupError) as ex: + status['message'] = str(ex) return status diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-501/rgw-501.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-501/rgw-501.component.html index 701048d4f7aa2..b9984b5cf2e8b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-501/rgw-501.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-501/rgw-501.component.html @@ -1,5 +1,5 @@ - {{ message }} + {{ message }}
Please consult the documentation on how to configure and enable the Object Gateway management functionality.
diff --git a/src/pybind/mgr/dashboard/services/rgw_client.py b/src/pybind/mgr/dashboard/services/rgw_client.py index 821949524d952..0f9deea6602f2 100644 --- a/src/pybind/mgr/dashboard/services/rgw_client.py +++ b/src/pybind/mgr/dashboard/services/rgw_client.py @@ -247,7 +247,7 @@ class RgwClient(RestClient): Consider the service as online if the response contains the specified keys. Nothing more is checked here. """ - request({'format': 'json'}) + _ = request({'format': 'json'}) return True @RestClient.api_get('/{admin_path}/metadata/user?myself', -- 2.39.5