From: Milind Changire Date: Wed, 2 Aug 2023 05:48:45 +0000 (+0530) Subject: qa: enhancement for subvol creation and mounting X-Git-Tag: v16.2.14~2^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=39f1fdaec5ecaf5fde281f38862aed4f2de93b46;p=ceph.git qa: enhancement for subvol creation and mounting Fixes: https://tracker.ceph.com/issues/54317 Signed-off-by: Milind Changire (cherry picked from commit bf83eaa4e75516a6937e4097b8708c48856a9473) --- diff --git a/qa/tasks/ceph.py b/qa/tasks/ceph.py index c9d361969c88..836e6ec704a2 100644 --- a/qa/tasks/ceph.py +++ b/qa/tasks/ceph.py @@ -445,6 +445,9 @@ def cephfs_setup(ctx, config): name = fs_config.pop('name') temp = deepcopy(cephfs_config) teuthology.deep_merge(temp, fs_config) + subvols = config.get('subvols', None) + if subvols: + teuthology.deep_merge(temp, {'subvols': subvols}) fs = Filesystem(ctx, fs_config=temp, name=name, create=True) if set_allow_multifs: fs.set_allow_multifs() diff --git a/qa/tasks/ceph_fuse.py b/qa/tasks/ceph_fuse.py index 2712229f9723..b443516230c0 100644 --- a/qa/tasks/ceph_fuse.py +++ b/qa/tasks/ceph_fuse.py @@ -72,6 +72,20 @@ def task(ctx, config): mount_timeout: 120 # default is 30, give up if /sys/ is not populated - interactive: + Example that creates and mounts a subvol: + + overrides: + ceph: + subvols: + create: 2 + subvol_options: "--namespace-isolated --size 25000000000" + ceph-fuse: + client.0: + mount_subvol_num: 0 + kclient: + client.1: + mount_subvol_num: 1 + :param ctx: Context :param config: Configuration """ diff --git a/qa/tasks/cephadm.py b/qa/tasks/cephadm.py index 07105c53d863..342c0d6416c6 100644 --- a/qa/tasks/cephadm.py +++ b/qa/tasks/cephadm.py @@ -818,7 +818,6 @@ def ceph_mdss(ctx, config): yield - @contextlib.contextmanager def ceph_monitoring(daemon_type, ctx, config): """ diff --git a/qa/tasks/cephfs/filesystem.py b/qa/tasks/cephfs/filesystem.py index d2b5885fa147..b2f762d39c18 100644 --- a/qa/tasks/cephfs/filesystem.py +++ b/qa/tasks/cephfs/filesystem.py @@ -751,6 +751,7 @@ class Filesystem(MDSCluster): raise if self.fs_config is not None: + log.debug(f"fs_config: {self.fs_config}") max_mds = self.fs_config.get('max_mds', 1) if max_mds > 1: self.set_max_mds(max_mds) @@ -763,6 +764,34 @@ class Filesystem(MDSCluster): if session_timeout != 60: self.set_session_timeout(session_timeout) + if self.fs_config.get('subvols', None) is not None: + log.debug(f"Creating {self.fs_config.get('subvols')} subvols " + f"for filesystem '{self.name}'") + if not hasattr(self._ctx, "created_subvols"): + self._ctx.created_subvols = dict() + + subvols = self.fs_config.get('subvols') + assert(isinstance(subvols, dict)) + assert(isinstance(subvols['create'], int)) + assert(subvols['create'] > 0) + + for sv in range(0, subvols['create']): + sv_name = f'sv_{sv}' + self.mon_manager.raw_cluster_cmd( + 'fs', 'subvolume', 'create', self.name, sv_name, + self.fs_config.get('subvol_options', '')) + + if self.name not in self._ctx.created_subvols: + self._ctx.created_subvols[self.name] = [] + + subvol_path = self.mon_manager.raw_cluster_cmd( + 'fs', 'subvolume', 'getpath', self.name, sv_name) + subvol_path = subvol_path.strip() + self._ctx.created_subvols[self.name].append(subvol_path) + else: + log.debug(f"Not Creating any subvols for filesystem '{self.name}'") + + self.getinfo(refresh = True) # wait pgs to be clean diff --git a/qa/tasks/cephfs/fuse_mount.py b/qa/tasks/cephfs/fuse_mount.py index 3bd759da82e5..982a5553496f 100644 --- a/qa/tasks/cephfs/fuse_mount.py +++ b/qa/tasks/cephfs/fuse_mount.py @@ -85,6 +85,7 @@ class FuseMount(CephFSMount): fuse_cmd += ['--id', self.client_id] if self.client_keyring_path and self.client_id is not None: fuse_cmd += ['-k', self.client_keyring_path] + self.validate_subvol_options() if self.cephfs_mntpt is not None: fuse_cmd += ["--client_mountpoint=" + self.cephfs_mntpt] if self.cephfs_name is not None: diff --git a/qa/tasks/cephfs/kernel_mount.py b/qa/tasks/cephfs/kernel_mount.py index 21be0c28710a..37c0f6210988 100644 --- a/qa/tasks/cephfs/kernel_mount.py +++ b/qa/tasks/cephfs/kernel_mount.py @@ -42,6 +42,8 @@ class KernelMount(CephFSMount): if not self.cephfs_mntpt: self.cephfs_mntpt = '/' + if not self.cephfs_name: + self.cephfs_name = 'cephfs' stderr = StringIO() try: diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index 9e7335124187..eb9fdfd2ec17 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -1387,3 +1387,22 @@ class CephFSMount(object): checksum_text = self.run_shell(cmd).stdout.getvalue().strip() checksum_sorted = sorted(checksum_text.split('\n'), key=lambda v: v.split()[1]) return hashlib.md5(('\n'.join(checksum_sorted)).encode('utf-8')).hexdigest() + + def validate_subvol_options(self): + mount_subvol_num = self.client_config.get('mount_subvol_num', None) + if self.cephfs_mntpt and mount_subvol_num is not None: + log.warning("You cannot specify both: cephfs_mntpt and mount_subvol_num") + log.info(f"Mounting subvol {mount_subvol_num} for now") + + if mount_subvol_num is not None: + # mount_subvol must be an index into the subvol path array for the fs + if not self.cephfs_name: + self.cephfs_name = 'cephfs' + assert(hasattr(self.ctx, "created_subvols")) + # mount_subvol must be specified under client.[0-9] yaml section + subvol_paths = self.ctx.created_subvols[self.cephfs_name] + path_to_mount = subvol_paths[mount_subvol_num] + self.cephfs_mntpt = path_to_mount + elif not self.cephfs_mntpt: + # default to the "/" path + self.cephfs_mntpt = "/"