From 82414b3a42258b09defe2a88bc937a096439534f 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 --- 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 78bbc316675..406d93ec52e 100644 --- a/src/pybind/mgr/devicehealth/module.py +++ b/src/pybind/mgr/devicehealth/module.py @@ -316,7 +316,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, "", "" @@ -341,7 +342,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, "", "" @@ -360,7 +362,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, "", "" @@ -385,6 +388,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