From: Kotresh HR Date: Tue, 1 Feb 2022 11:06:34 +0000 (+0530) Subject: mgr/volumes: Fix subvolumegroup ls X-Git-Tag: v18.0.0~1360^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a125b0e8a22ba6c8d14f25fe85ce8d0771299c6c;p=ceph.git mgr/volumes: Fix subvolumegroup ls The subvolumegroup ls listed '_deleting' directory which is internal to 'mgr/volumes' and should not be listed as a subvolumegroup. This patch fixes the same by filtering it. Fixes: https://tracker.ceph.com/issues/54099 Signed-off-by: Kotresh HR --- diff --git a/src/pybind/mgr/volumes/fs/fs_util.py b/src/pybind/mgr/volumes/fs/fs_util.py index 3d098ddb0588e..c66448a94c810 100644 --- a/src/pybind/mgr/volumes/fs/fs_util.py +++ b/src/pybind/mgr/volumes/fs/fs_util.py @@ -58,16 +58,20 @@ def volume_exists(mgr, fs_name): return True return False -def listdir(fs, dirpath): +def listdir(fs, dirpath, filter_entries=None): """ Get the directory names (only dirs) for a given path """ dirs = [] + if filter_entries is None: + filter_entries = [b".", b".."] + else: + filter_entries.extend([b".", b".."]) try: with fs.opendir(dirpath) as dir_handle: d = fs.readdir(dir_handle) while d: - if (d.d_name not in (b".", b"..")) and d.is_dir(): + if (d.d_name not in filter_entries) and d.is_dir(): dirs.append(d.d_name) d = fs.readdir(dir_handle) except cephfs.Error as e: diff --git a/src/pybind/mgr/volumes/fs/volume.py b/src/pybind/mgr/volumes/fs/volume.py index a3496d94229f7..6a295ff2bc6b2 100644 --- a/src/pybind/mgr/volumes/fs/volume.py +++ b/src/pybind/mgr/volumes/fs/volume.py @@ -14,6 +14,7 @@ from .operations.volume import create_volume, \ from .operations.group import open_group, create_group, remove_group, open_group_unique from .operations.subvolume import open_subvol, create_subvol, remove_subvol, \ create_clone +from .operations.trash import Trash from .vol_spec import VolSpec from .exception import VolumeException, ClusterError, ClusterTimeout, EvictionError @@ -626,7 +627,7 @@ class VolumeClient(CephfsClient["Module"]): try: with open_volume(self, volname) as fs_handle: volume_exists = True - groups = listdir(fs_handle, self.volspec.base_dir) + groups = listdir(fs_handle, self.volspec.base_dir, filter_entries=[Trash.GROUP_NAME.encode('utf-8')]) ret = 0, name_to_json(groups), "" except VolumeException as ve: if not ve.errno == -errno.ENOENT or not volume_exists: