Skip to content

Commit e99486e

Browse files
dparmar18YiteGu
authored andcommitted
mgr/dashboard: allow sending back error status code fetching clients fails
Fixes: https://tracker.ceph.com/issues/64089 Signed-off-by: Dhairya Parmar <[email protected]> (cherry picked from commit 564dba3)
1 parent 3cb0412 commit e99486e

File tree

1 file changed

+22
-6
lines changed
  • src/pybind/mgr/dashboard/controllers

1 file changed

+22
-6
lines changed

src/pybind/mgr/dashboard/controllers/cephfs.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,17 @@ def get(self, fs_id):
105105
return self.fs_status(fs_id)
106106

107107
@RESTController.Resource('GET')
108-
def clients(self, fs_id):
108+
def clients(self, fs_id, **kwargs):
109+
flag = kwargs.pop('suppress_client_ls_errors', 'True')
110+
if flag not in ('True', 'False'):
111+
raise DashboardException(msg='suppress_client_ls_errors value '
112+
'needs to be either True or False '
113+
f'but provided {flag}',
114+
component='cephfs')
115+
109116
fs_id = self.fs_id_to_int(fs_id)
110117

111-
return self._clients(fs_id)
118+
return self._clients(fs_id, suppress_client_ls_errors=flag)
112119

113120
@RESTController.Resource('DELETE', path='/client/{client_id}')
114121
def evict(self, fs_id, client_id):
@@ -351,17 +358,23 @@ def fs_status(self, fs_id):
351358
"versions": mds_versions
352359
}
353360

354-
def _clients(self, fs_id):
361+
def _clients(self, fs_id, **kwargs):
362+
suppress_get_errors = kwargs.pop('suppress_client_ls_errors', 'True')
355363
cephfs_clients = self.cephfs_clients.get(fs_id, None)
356364
if cephfs_clients is None:
357365
cephfs_clients = CephFSClients(mgr, fs_id)
358366
self.cephfs_clients[fs_id] = cephfs_clients
359367

360368
try:
361-
status, clients = cephfs_clients.get()
369+
status, clients = cephfs_clients.get(suppress_get_errors)
362370
except AttributeError:
363371
raise cherrypy.HTTPError(404,
364372
"No cephfs with id {0}".format(fs_id))
373+
except RuntimeError:
374+
raise cherrypy.HTTPError(500,
375+
f"Could not fetch client(s), maybe there "
376+
f"is no active MDS on CephFS {fs_id} or "
377+
"the FS is in failed state.")
365378

366379
if clients is None:
367380
raise cherrypy.HTTPError(404,
@@ -609,11 +622,14 @@ def __init__(self, module_inst, fscid):
609622
self.fscid = fscid
610623

611624
@ViewCache()
612-
def get(self):
625+
def get(self, suppress_errors='True'):
613626
try:
614627
ret = CephService.send_command('mds', 'session ls', srv_spec='{0}:0'.format(self.fscid))
615628
except RuntimeError:
616-
ret = []
629+
if suppress_errors == 'True':
630+
ret = []
631+
else:
632+
raise
617633
return ret
618634

619635

0 commit comments

Comments
 (0)