From 7a99e0e524f39d42daba693ccef09b3c8cdcc1a7 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 16 May 2024 16:32:22 -0400 Subject: [PATCH] Fix bugs listing snapshots by pool/volume The logic of this didn't work, so reconfigure to use these like limits. Also fixes a bug in the upper getCephVolumes for invalid pools. --- daemon-common/ceph.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/daemon-common/ceph.py b/daemon-common/ceph.py index b6289d68..720c9590 100644 --- a/daemon-common/ceph.py +++ b/daemon-common/ceph.py @@ -540,7 +540,10 @@ def getCephVolumes(zkhandler, pool): pool_list = [pool] for pool_name in pool_list: - for volume_name in zkhandler.children(("volume", pool_name)): + children = zkhandler.children(("volume", pool_name)) + if children is None: + continue + for volume_name in children: volume_list.append("{}/{}".format(pool_name, volume_name)) return volume_list @@ -1153,20 +1156,9 @@ def remove_snapshot(zkhandler, pool, volume, name): ) -def get_list_snapshot(zkhandler, pool, volume, limit=None, is_fuzzy=True): +def get_list_snapshot(zkhandler, target_pool, target_volume, limit=None, is_fuzzy=True): snapshot_list = [] - if pool and not verifyPool(zkhandler, pool): - return False, 'ERROR: No pool with name "{}" is present in the cluster.'.format( - pool - ) - - if volume and not verifyPool(zkhandler, volume): - return ( - False, - 'ERROR: No volume with name "{}" is present in the cluster.'.format(volume), - ) - - full_snapshot_list = getCephSnapshots(zkhandler, pool, volume) + full_snapshot_list = getCephSnapshots(zkhandler, target_pool, target_volume) if is_fuzzy and limit: # Implicitly assume fuzzy limits @@ -1178,6 +1170,10 @@ def get_list_snapshot(zkhandler, pool, volume, limit=None, is_fuzzy=True): for snapshot in full_snapshot_list: volume, snapshot_name = snapshot.split("@") pool_name, volume_name = volume.split("/") + if target_pool and pool_name != target_pool: + continue + if target_volume and volume_name != target_volume: + continue if limit: try: if re.fullmatch(limit, snapshot_name):