]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: NFS pages shows 'Page not found' 44507/head
authorVolker Theile <vtheile@suse.com>
Mon, 10 Jan 2022 11:16:20 +0000 (12:16 +0100)
committerVolker Theile <vtheile@suse.com>
Tue, 11 Jan 2022 09:51:36 +0000 (10:51 +0100)
Fixes: https://tracker.ceph.com/issues/53813
Signed-off-by: Volker Theile <vtheile@suse.com>
src/pybind/mgr/dashboard/controllers/nfs.py
src/pybind/mgr/dashboard/tests/test_nfs.py

index 5c9f05c3ed700859b11f4edab3abbfd8e65622b6..d14b5402863c10aa59988208e238872e249e50b7 100644 (file)
@@ -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
index 087ca18914b95c781b8b6a150ed140e0b28fd7a4..c0103653f96d66beb17c3d95ebed7f66f3b9c496 100644 (file)
@@ -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'})