From: Rishabh Dave Date: Sat, 12 Apr 2025 16:45:29 +0000 (+0530) Subject: mgr/vol: fix test_subvolume_retain_snapshot_recreate X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6c43cbed2dfabc19aab122f0716a5d71ce46353f;p=ceph-ci.git mgr/vol: fix test_subvolume_retain_snapshot_recreate 2 issues had to be in fixed this test - 1. list_snapshots() needs to be re-defined in v3 since snapshots from previous incarnations can also have retained snapshots and those too needs to be listed. 2. snapshot_data_path() needs to be re-defined to cover the case where the snapshot doesn't belong to currrent incarnation but to one of the previous incarnation. These issues were triggered by the part of the test that re-creates a subvolume from its own snapshot that was retained during previous deletion. Thus, snapshot doesn't belong to current incarnation and therefore caused these methods to fail. Signed-off-by: Rishabh Dave --- diff --git a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v3.py b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v3.py index 0152eedac25..6f564d53d25 100644 --- a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v3.py +++ b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v3.py @@ -310,7 +310,16 @@ class SubvolumeV3(SubvolumeV2): def snapshot_data_path(self, snap_name): - snap_path = join(self.snapshot_path(snap_name), b'mnt') + uuid = self.get_incar_uuid_for_snap(snap_name) + if uuid == None: + raise VolumeException(-errno.ENOENT, + f'snapshot \'{snap_name}\' does not exist') + elif uuid == self.uuid: + snap_path = join(self.snapshot_path(snap_name), b'mnt') + else: + snap_path = join(self.roots_dir, uuid, + self.vol_spec.snapshot_dir_prefix.encode('utf-8'), + snap_name.encode('utf-8'), b'mnt') # v2 raises exception if the snapshot path do not exist so do the same # to prevent any bugs due to difference in behaviour. @@ -330,3 +339,19 @@ class SubvolumeV3(SubvolumeV2): raise VolumeException(-e.args[0], e.args[1]) return snap_path + + def list_snapshots(self): + ''' + Return list of name of all snapshots from all the incarnations. + ''' + all_snap_names = [] + + # list of all incarnations/UUID dirs of this subvolume. + incars = listdir(self.fs, self.roots_dir) + + for incar_uuid in incars: + # construct path to ".snap" directory for given UUID. + snap_dir = join(self.roots_dir, incar_uuid, + self.vol_spec.snapshot_dir_prefix.encode('utf-8')) + all_snap_names.extend(listdir(self.fs, snap_dir)) + return all_snap_names