From 97329bb90d7b0d3c5705cbdb392c186e87158cb7 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Mon, 22 Jul 2024 13:26:27 -0400 Subject: [PATCH] Sort Ceph pool data by name There is no guarantee that both commands output the pools in the same order, so sort them by name first so the iteration over the pools by ID is successful. --- node-daemon/pvcnoded/util/keepalive.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/node-daemon/pvcnoded/util/keepalive.py b/node-daemon/pvcnoded/util/keepalive.py index c5be47f6..29fbf8f8 100644 --- a/node-daemon/pvcnoded/util/keepalive.py +++ b/node-daemon/pvcnoded/util/keepalive.py @@ -157,7 +157,9 @@ def collect_ceph_stats(logger, config, zkhandler, this_node, queue): 1 ].decode("ascii") try: - ceph_pool_df_raw = json.loads(ceph_df_output)["pools"] + ceph_pool_df_raw = sorted( + json.loads(ceph_df_output)["pools"], key=lambda x: x["name"] + ) except Exception as e: logger.out("Failed to obtain Pool data (ceph df): {}".format(e), state="w") ceph_pool_df_raw = [] @@ -166,7 +168,9 @@ def collect_ceph_stats(logger, config, zkhandler, this_node, queue): "rados df --format json", timeout=1 ) try: - rados_pool_df_raw = json.loads(stdout)["pools"] + rados_pool_df_raw = sorted( + json.loads(stdout)["pools"], key=lambda x: x["name"] + ) except Exception as e: logger.out("Failed to obtain Pool data (rados df): {}".format(e), state="w") rados_pool_df_raw = []