]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/devicehealth: skip null pages when extracting wear level 45141/head
authorYaarit Hatuka <yaarit@redhat.com>
Tue, 22 Feb 2022 19:22:09 +0000 (19:22 +0000)
committerSridhar Seshasayee <sseshasa@redhat.com>
Thu, 24 Feb 2022 08:19:41 +0000 (13:49 +0530)
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 <yaarit@redhat.com>
(cherry picked from commit 2864ac30d4170ba7b5f60ae01ecfdeee707e026a)

src/pybind/mgr/devicehealth/module.py

index 9b6c1fe431c508523ff95b7a398547ff1a2f1eae..056e28208cfe7d530337d3ba6ec1d890fb8c6aa4 100644 (file)
@@ -29,7 +29,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: