]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: The /rgw/status endpoint does not check for running service 38770/head
authorVolker Theile <vtheile@suse.com>
Thu, 10 Dec 2020 14:30:16 +0000 (15:30 +0100)
committerVolker Theile <vtheile@suse.com>
Tue, 5 Jan 2021 14:24:30 +0000 (15:24 +0100)
Fixes: https://tracker.ceph.com/issues/48542
Signed-off-by: Volker Theile <vtheile@suse.com>
(cherry picked from commit 3cfe054d42cbdc5fa731626b27ecaf9ac0baa31e)

src/pybind/mgr/dashboard/controllers/rgw.py
src/pybind/mgr/dashboard/tests/test_rgw.py

index 31271514850328aa172cfad0f8c16356508ada02..55a6fbcddb7d3d038ea01dad4fbfad8e61d7aad5 100644 (file)
@@ -30,6 +30,8 @@ class Rgw(BaseController):
     def status(self):
         status = {'available': False, 'message': None}
         try:
+            if not CephService.get_service_list('rgw'):
+                raise LookupError('No RGW service is running.')
             instance = RgwClient.admin_instance()
             # Check if the service is online.
             if not instance.is_service_online():  # pragma: no cover - no complexity there
index 2c90e7d11be1dea7da026155586627ee7510caa4..1a99db59287cda3720d948cfb0e007a00f27e3d1 100644 (file)
@@ -3,8 +3,22 @@ try:
 except ImportError:
     import unittest.mock as mock
 
-from . import ControllerTestCase
-from ..controllers.rgw import RgwUser
+from .. import mgr
+from ..controllers.rgw import Rgw, RgwUser
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
+
+
+class RgwControllerTestCase(ControllerTestCase):
+    @classmethod
+    def setup_server(cls):
+        Rgw._cp_config['tools.authenticate.on'] = False  # pylint: disable=protected-access
+        cls.setup_controllers([Rgw], '/test')
+
+    def test_status_no_service(self):
+        mgr.list_servers.return_value = []
+        self._get('/test/api/rgw/status')
+        self.assertStatus(200)
+        self.assertJsonBody({'available': False, 'message': 'No RGW service is running.'})
 
 
 class RgwUserControllerTestCase(ControllerTestCase):