From 534a612ad359bab5b40f16150d11d39b6c3c880e Mon Sep 17 00:00:00 2001 From: Yaarit Hatuka Date: Tue, 22 Feb 2022 19:22:09 +0000 Subject: [PATCH] mgr/devicehealth: skip null pages when extracting wear level Some devices have null pages in their ata_device_statistics struct; skip those pages in order to avoid an AttributeError when extracting device's wear level. Fixes: https://tracker.ceph.com/issues/51554 Signed-off-by: Yaarit Hatuka (cherry picked from commit 2864ac30d4170ba7b5f60ae01ecfdeee707e026a) --- src/pybind/mgr/devicehealth/module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pybind/mgr/devicehealth/module.py b/src/pybind/mgr/devicehealth/module.py index 44ca3bab8819e..110e00bf7efc8 100644 --- a/src/pybind/mgr/devicehealth/module.py +++ b/src/pybind/mgr/devicehealth/module.py @@ -30,7 +30,7 @@ def get_ata_wear_level(data: Dict[Any,Any]) -> Optional[float]: Extract wear level (as float) from smartctl -x --json output for SATA SSD """ for page in data.get("ata_device_statistics", {}).get("pages", []): - if page.get("number") != 7: + if page is None or page.get("number") != 7: continue for item in page.get("table", []): if item["offset"] == 8: -- 2.39.5