From aa035cfcf6a4d34d00d3a589c039a11dbe3ce1ed Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 7 Nov 2019 16:35:19 -0600 Subject: [PATCH] mgr/devicehealth: ensure we don't store empty objects I'm not sure why devid would end up empty, but it is possible if we get wonky data, and users seem to have seen empty objects in their pools, so add a check! Maybe-fixes: https://tracker.ceph.com/issues/41383 Signed-off-by: Sage Weil (cherry picked from commit 82414b3a42258b09defe2a88bc937a096439534f) --- src/pybind/mgr/devicehealth/module.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/devicehealth/module.py b/src/pybind/mgr/devicehealth/module.py index 092aa906388d4..d187d0e6f7bce 100644 --- a/src/pybind/mgr/devicehealth/module.py +++ b/src/pybind/mgr/devicehealth/module.py @@ -318,7 +318,8 @@ class Module(MgrModule): if raw_smart_data: for device, raw_data in raw_smart_data.items(): data = self.extract_smart_features(raw_data) - self.put_device_metrics(ioctx, device, data) + if device and data: + self.put_device_metrics(ioctx, device, data) ioctx.close() return 0, "", "" @@ -340,7 +341,8 @@ class Module(MgrModule): continue did_device[device] = 1 data = self.extract_smart_features(raw_data) - self.put_device_metrics(ioctx, device, data) + if device and data: + self.put_device_metrics(ioctx, device, data) ioctx.close() return 0, "", "" @@ -359,7 +361,8 @@ class Module(MgrModule): if raw_smart_data: for device, raw_data in raw_smart_data.items(): data = self.extract_smart_features(raw_data) - self.put_device_metrics(ioctx, device, data) + if device and data: + self.put_device_metrics(ioctx, device, data) ioctx.close() return 0, "", "" @@ -384,6 +387,7 @@ class Module(MgrModule): daemon_type, daemon_id, outb)) def put_device_metrics(self, ioctx, devid, data): + assert devid old_key = datetime.utcnow() - timedelta( seconds=int(self.retention_period)) prune = old_key.strftime(TIME_FORMAT) -- 2.39.5