From 417517c62439113cbad58676aa782b8ce13b3f4f Mon Sep 17 00:00:00 2001 From: Patrick Seidensal Date: Wed, 23 Oct 2019 14:31:36 +0200 Subject: [PATCH] mgr/dashboard: AttributeError: 'NoneType' object has no attribute 'items' in smart data integration Fixes: https://tracker.ceph.com/issues/42443 Signed-off-by: Patrick Seidensal --- src/pybind/mgr/dashboard/controllers/osd.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/osd.py b/src/pybind/mgr/dashboard/controllers/osd.py index e9eb229aff2..32dd5680968 100644 --- a/src/pybind/mgr/dashboard/controllers/osd.py +++ b/src/pybind/mgr/dashboard/controllers/osd.py @@ -57,6 +57,7 @@ class Osd(RESTController): def add_id(osd): osd['id'] = osd['osd'] return osd + resp = { osd['osd']: add_id(osd) for osd in mgr.get('osd_map')['osds'] if svc_id is None or osd['osd'] == int(svc_id) @@ -77,11 +78,13 @@ class Osd(RESTController): if dev_id not in smart_data: dev_smart_data = mgr.remote('devicehealth', 'do_scrape_daemon', 'osd', svc_id, dev_id) - for _, dev_data in dev_smart_data.items(): - if 'error' in dev_data: - logger.warning('[OSD] Error retrieving smartctl data for device ID %s: %s', - dev_id, dev_smart_data) - smart_data.update(dev_smart_data) + if dev_smart_data: + for _, dev_data in dev_smart_data.items(): + if 'error' in dev_data: + logger.warning( + '[OSD] Error retrieving smartctl data for device ID %s: %s', dev_id, + dev_smart_data) + smart_data.update(dev_smart_data) return smart_data @RESTController.Resource('GET') -- 2.39.5