From 9ca02171543deca489c3e99c46db40c07ef1593b Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Wed, 4 Jun 2025 23:51:12 -0400 Subject: [PATCH] Avoid fatal faults if volume stats are invalid Returns garbage data, but avoids causing the entire API call to fail if this happens on very old clusters (or after any sort of ZK corruption). --- daemon-common/ceph.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/daemon-common/ceph.py b/daemon-common/ceph.py index 18408ebb..92bd909b 100644 --- a/daemon-common/ceph.py +++ b/daemon-common/ceph.py @@ -555,9 +555,16 @@ def getCephVolumes(zkhandler, pool): def getVolumeInformation(zkhandler, pool, volume): # Parse the stats data volume_stats_raw = zkhandler.read(("volume.stats", f"{pool}/{volume}")) - volume_stats = dict(json.loads(volume_stats_raw)) - # Format the size to something nicer - volume_stats["size"] = format_bytes_tohuman(volume_stats["size"]) + try: + volume_stats = dict(json.loads(volume_stats_raw)) + # Format the size to something nicer + volume_stats["size"] = format_bytes_tohuman(volume_stats["size"]) + except Exception: + volume_stats = dict( + json.loads( + f'{"name":"{volume}","id":"","size":0,"objects":0,"order":0,"object_size":0,"snapshot_count":0,"block_name_prefix":"","format":0,"features":[],"op_features":[],"flags":[],"create_timestamp":"","access_timestamp":"","modify_timestamp":""}' + ) + ) volume_information = {"name": volume, "pool": pool, "stats": volume_stats} return volume_information