From f6e99ee05a2f5ff145736014aeb5184cdc8259bb Mon Sep 17 00:00:00 2001 From: Volker Theile Date: Mon, 10 Jan 2022 12:16:20 +0100 Subject: [PATCH] mgr/dashboard: NFS pages shows 'Page not found' Fixes: https://tracker.ceph.com/issues/53813 Signed-off-by: Volker Theile --- src/pybind/mgr/dashboard/controllers/nfs.py | 2 +- src/pybind/mgr/dashboard/tests/test_nfs.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/nfs.py b/src/pybind/mgr/dashboard/controllers/nfs.py index 5c9f05c3ed700..d14b5402863c1 100644 --- a/src/pybind/mgr/dashboard/controllers/nfs.py +++ b/src/pybind/mgr/dashboard/controllers/nfs.py @@ -96,7 +96,7 @@ class NFSGanesha(RESTController): status = {'available': True, 'message': None} try: mgr.remote('nfs', 'cluster_ls') - except ImportError as error: + except (ImportError, RuntimeError) as error: logger.exception(error) status['available'] = False status['message'] = str(error) # type: ignore diff --git a/src/pybind/mgr/dashboard/tests/test_nfs.py b/src/pybind/mgr/dashboard/tests/test_nfs.py index 087ca18914b95..c0103653f96d6 100644 --- a/src/pybind/mgr/dashboard/tests/test_nfs.py +++ b/src/pybind/mgr/dashboard/tests/test_nfs.py @@ -6,7 +6,7 @@ from urllib.parse import urlencode from .. import mgr from ..controllers._version import APIVersion -from ..controllers.nfs import NFSGaneshaExports, NFSGaneshaUi +from ..controllers.nfs import NFSGanesha, NFSGaneshaExports, NFSGaneshaUi from ..tests import ControllerTestCase from ..tools import NotificationQueue, TaskManager @@ -227,3 +227,20 @@ class NFSGaneshaUiControllerTest(ControllerTestCase): cephfs_class.return_value.ls_dir.assert_called_once_with('/foo', 3) self.assertStatus(200) self.assertJsonBody({'paths': []}) + + +class NFSGaneshaControllerTest(ControllerTestCase): + @classmethod + def setup_server(cls): + cls.setup_controllers([NFSGanesha]) + + def test_status_available(self): + self._get('/api/nfs-ganesha/status') + self.assertStatus(200) + self.assertJsonBody({'available': True, 'message': None}) + + def test_status_not_available(self): + mgr.remote = Mock(side_effect=RuntimeError('Test')) + self._get('/api/nfs-ganesha/status') + self.assertStatus(200) + self.assertJsonBody({'available': False, 'message': 'Test'}) -- 2.39.5