Skip to content

Commit 5dbd3bf

Browse files
committed
Merge PR ceph#52258 into main
* refs/pull/52258/head: client: check mds down status bofore getting mds_gid_t from mdsmap mgr/dashboard: allow sending back error status code fetching clients fails Reviewed-by: Xiubo Li <[email protected]> Reviewed-by: Venky Shankar <[email protected]> Reviewed-by: Rishabh Dave <[email protected]> Reviewed-by: Patrick Donnelly <[email protected]> Reviewed-by: Nizamudeen A <[email protected]> Reviewed-by: Dhairya Parmar <[email protected]>
2 parents 29d5e8d + 878463e commit 5dbd3bf

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

qa/tasks/mgr/dashboard/test_cephfs.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,17 @@ def test_statfs(self):
347347
self.assertEqual(stats['subdirs'], 1)
348348

349349
self.rm_dir('/animal')
350+
351+
def test_cephfs_clients_get_after_mds_down(self):
352+
fs_id = self.get_fs_id()
353+
self._get(f"/api/cephfs/{fs_id}/clients")
354+
self.assertStatus(200)
355+
356+
self.fs.fail()
357+
params = {'suppress_client_ls_errors': 'False'}
358+
self._get(f"/api/cephfs/{fs_id}/clients", params=params)
359+
self.assertStatus(500)
360+
361+
self.fs.set_joinable()
362+
self._get(f"/api/cephfs/{fs_id}/clients")
363+
self.assertStatus(200)

src/client/Client.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6273,6 +6273,11 @@ int Client::resolve_mds(
62736273
if (role_r == 0) {
62746274
// We got a role, resolve it to a GID
62756275
const auto& mdsmap = fsmap->get_filesystem(role.fscid).get_mds_map();
6276+
if (mdsmap.is_down(role.rank)) {
6277+
lderr(cct) << __func__ << ": targets rank: " << role.rank
6278+
<< " is down" << dendl;
6279+
return -CEPHFS_EAGAIN;
6280+
}
62766281
auto& info = mdsmap.get_info(role.rank);
62776282
ldout(cct, 10) << __func__ << ": resolved " << mds_spec << " to role '"
62786283
<< role << "' aka " << info.human_name() << dendl;

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

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

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

112-
return self._clients(fs_id)
119+
return self._clients(fs_id, suppress_client_ls_errors=flag)
113120

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

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

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

367380
if clients is None:
368381
raise cherrypy.HTTPError(404,
@@ -610,11 +623,14 @@ def __init__(self, module_inst, fscid):
610623
self.fscid = fscid
611624

612625
@ViewCache()
613-
def get(self):
626+
def get(self, suppress_errors='True'):
614627
try:
615628
ret = CephService.send_command('mds', 'session ls', srv_spec='{0}:0'.format(self.fscid))
616629
except RuntimeError:
617-
ret = []
630+
if suppress_errors == 'True':
631+
ret = []
632+
else:
633+
raise
618634
return ret
619635

620636

0 commit comments

Comments
 (0)