]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Improve exception handling in /api/rgw/status 25836/head
authorVolker Theile <vtheile@suse.com>
Tue, 8 Jan 2019 14:24:59 +0000 (15:24 +0100)
committerVolker Theile <vtheile@suse.com>
Wed, 16 Jan 2019 09:55:35 +0000 (10:55 +0100)
In some cases the exception message was not forwarded to the caller.

Signed-off-by: Volker Theile <vtheile@suse.com>
src/pybind/mgr/dashboard/controllers/rgw.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-501/rgw-501.component.html
src/pybind/mgr/dashboard/services/rgw_client.py

index 83679d28ae8cd8f40f22e704675627add28592e0..871fa00fdf4eefde1c9dbed24437c62e7fbaa97f 100644 (file)
@@ -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
 
 
index 701048d4f7aa249c990fbff6f1cd89c4226ccbbe..b9984b5cf2e8be050876e6c262f1d027988a1efa 100644 (file)
@@ -1,5 +1,5 @@
 <cd-info-panel>
-  {{ message }}
+  {{ message }}<br>
   <ng-container i18n>Please consult the <a href="{{docsUrl}}" target="_blank">documentation</a>
   on how to configure and enable the Object Gateway management functionality.</ng-container>
 </cd-info-panel>
index 821949524d9527807aa301204b8825c2189007fc..0f9deea6602f21cf2f977509427a47ca697bcfec 100644 (file)
@@ -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',