Skip to content

Commit

Permalink
mgr/dashboard: The /rgw/status endpoint does not check for running se…
Browse files Browse the repository at this point in the history
…rvice

Fixes: https://tracker.ceph.com/issues/48542

Signed-off-by: Volker Theile <[email protected]>
  • Loading branch information
votdev committed Dec 10, 2020
1 parent b32c6f1 commit 3cfe054
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/pybind/mgr/dashboard/controllers/rgw.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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
Expand Down
16 changes: 15 additions & 1 deletion src/pybind/mgr/dashboard/tests/test_rgw.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@
except ImportError:
import unittest.mock as mock

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):
@classmethod
def setup_server(cls):
Expand Down

0 comments on commit 3cfe054

Please sign in to comment.