]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/services/ceph_service.py
import quincy beta 17.1.0
[ceph.git] / ceph / src / pybind / mgr / dashboard / services / ceph_service.py
index 3492b96549806baa9de025f5ddc8dde336916a99..b261dc6b02b0c8d879939500e7933e63a12d7304 100644 (file)
@@ -1,5 +1,4 @@
 # -*- coding: utf-8 -*-
-from __future__ import absolute_import
 
 import json
 import logging
@@ -9,7 +8,6 @@ from mgr_module import CommandResult
 from mgr_util import get_most_recent_rate, get_time_series_rates
 
 from .. import mgr
-from ..exceptions import DashboardException
 
 try:
     from typing import Any, Dict, Optional, Union
@@ -236,11 +234,7 @@ class CephService(object):
         # type: (dict) -> Dict[str, dict]
         # Check whether the device is associated with daemons.
         if 'daemons' in device and device['daemons']:
-            dev_smart_data = None
-
-            # The daemons associated with the device. Note, the list may
-            # contain daemons that are 'down' or 'destroyed'.
-            daemons = device.get('daemons')
+            dev_smart_data: Dict[str, Any] = {}
 
             # Get a list of all OSD daemons on all hosts that are 'up'
             # because SMART data can not be retrieved from daemons that
@@ -251,26 +245,27 @@ class CephService(object):
                 if node.get('status') == 'up'
             ]
 
-            # Finally get the daemons on the host of the given device
-            # that are 'up'. All daemons on the same host can deliver
-            # SMART data, thus it is not relevant for us which daemon
-            # we are using.
-            daemons = list(set(daemons) & set(osd_daemons_up))  # type: ignore
-
-            for daemon in daemons:
+            # All daemons on the same host can deliver SMART data,
+            # thus it is not relevant for us which daemon we are using.
+            # NOTE: the list may contain daemons that are 'down' or 'destroyed'.
+            for daemon in device['daemons']:
                 svc_type, svc_id = daemon.split('.')
                 if 'osd' in svc_type:
+                    if daemon not in osd_daemons_up:
+                        continue
                     try:
                         dev_smart_data = CephService.send_command(
                             svc_type, 'smart', svc_id, devid=device['devid'])
-                    except SendCommandError:
+                    except SendCommandError as error:
+                        logger.warning(str(error))
                         # Try to retrieve SMART data from another daemon.
                         continue
                 elif 'mon' in svc_type:
                     try:
                         dev_smart_data = CephService.send_command(
                             svc_type, 'device query-daemon-health-metrics', who=daemon)
-                    except SendCommandError:
+                    except SendCommandError as error:
+                        logger.warning(str(error))
                         # Try to retrieve SMART data from another daemon.
                         continue
                 else:
@@ -281,10 +276,7 @@ class CephService(object):
                             '[SMART] Error retrieving smartctl data for device ID "%s": %s',
                             dev_id, dev_data)
                 break
-            if dev_smart_data is None:
-                raise DashboardException(
-                    'Failed to retrieve SMART data for device ID "{}"'.format(
-                        device['devid']))
+
             return dev_smart_data
         logger.warning('[SMART] No daemons associated with device ID "%s"',
                        device['devid'])