]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Device health status is not getting listed under hosts section 40494/head
authorAashish Sharma <aashishsharma@localhost.localdomain>
Thu, 11 Mar 2021 06:06:22 +0000 (11:36 +0530)
committerAashish Sharma <aashishsharma@localhost.localdomain>
Tue, 30 Mar 2021 08:28:37 +0000 (13:58 +0530)
Device health is shown as failed to retrieve data under Hosts > Device Health section. This PR intends to fix this issue.

Fixes: https://tracker.ceph.com/issues/49354
Signed-off-by: Aashish Sharma <aasharma@redhat.com>
(cherry picked from commit 8f4574696c5272de4be6cbcbd3a8fc713d6b604e)

src/pybind/mgr/dashboard/services/ceph_service.py
src/pybind/mgr/dashboard/tests/test_ceph_service.py

index 7b2aa5fde55a5a1cd808467d5da01a0b56bd37bd..4cf82f06696d87341b6694c06dafe70fbbbf6aa2 100644 (file)
@@ -232,12 +232,20 @@ class CephService(object):
 
             for daemon in daemons:
                 svc_type, svc_id = daemon.split('.')
-                try:
-                    dev_smart_data = CephService.send_command(
-                        svc_type, 'smart', svc_id, devid=device['devid'])
-                except SendCommandError:
-                    # Try to retrieve SMART data from another daemon.
-                    continue
+                if 'osd' in svc_type:
+                    try:
+                        dev_smart_data = CephService.send_command(
+                            svc_type, 'smart', svc_id, devid=device['devid'])
+                    except SendCommandError:
+                        # Try to retrieve SMART data from another daemon.
+                        continue
+                else:
+                    try:
+                        dev_smart_data = CephService.send_command(
+                            svc_type, 'device get-health-metrics', svc_id, devid=device['devid'])
+                    except SendCommandError:
+                        # Try to retrieve SMART data from another daemon.
+                        continue
                 for dev_id, dev_data in dev_smart_data.items():
                     if 'error' in dev_data:
                         logger.warning(
index 3433443b1701d927382a7b2886e3792337641cad..9a8ca674c23634639192b8ab5e46a00d9eb3c172 100644 (file)
@@ -107,3 +107,23 @@ def test_get_smart_data(caplog, by, args, log):
             CephService._get_smart_data_by_device.assert_not_called()
             assert smart_data == {}
             assert log in caplog.text
+
+
+@mock.patch.object(CephService, 'send_command')
+def test_get_smart_data_from_appropriate_ceph_command(send_command):
+    # pylint: disable=protected-access
+    send_command.side_effect = [
+        {'nodes': [{'name': 'osd.1', 'status': 'up'}, {'name': 'mon.1', 'status': 'down'}]},
+        {'fake': {'device': {'name': '/dev/sda'}}}
+    ]
+    CephService._get_smart_data_by_device({'devid': '1', 'daemons': ['osd.1', 'mon.1']})
+    send_command.assert_has_calls([mock.call('mon', 'osd tree'),
+                                   mock.call('osd', 'smart', '1', devid='1')])
+
+    send_command.side_effect = [
+        {'nodes': [{'name': 'osd.1', 'status': 'down'}, {'name': 'mon.1', 'status': 'up'}]},
+        {'fake': {'device': {'name': '/dev/sda'}}}
+    ]
+    CephService._get_smart_data_by_device({'devid': '1', 'daemons': ['osd.1', 'mon.1']})
+    send_command.assert_has_calls([mock.call('mon', 'osd tree'),
+                                   mock.call('mon', 'device get-health-metrics', '1', devid='1')])