From: Kotresh HR Date: Wed, 11 Jun 2025 07:04:04 +0000 (+0530) Subject: qa: Honor cephfs config from yaml across test cases X-Git-Tag: testing/wip-vshankar-testing-20250805.100115-debug^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=38c0e441e3dbaff0df1928387158e51f3dd91e33;p=ceph-ci.git qa: Honor cephfs config from yaml across test cases The cephfs_test_runner wasn't honoring the cephfs config passed via yaml. For each test case the filesystem is newly created and destroyed as part of setup and teardown. The filesystem creation is taken care by the class 'Filesystem' in which the 'fs_config' isn't initialised from yaml. Hence the filesystem is being created with default configs without honoring the configs passed from yaml. This patch fixes the same. Fixes: https://tracker.ceph.com/issues/71649 Signed-off-by: Kotresh HR --- diff --git a/qa/tasks/ceph.py b/qa/tasks/ceph.py index af55c9a1b2b..3288e53d3b2 100644 --- a/qa/tasks/ceph.py +++ b/qa/tasks/ceph.py @@ -496,6 +496,8 @@ def cephfs_setup(ctx, config): if mdss.remotes: log.info('Setting up CephFS filesystem(s)...') cephfs_config = config.get('cephfs', {}) + ctx.cephfs_config = deepcopy(cephfs_config) + ctx.subvols = deepcopy(config.get('subvols', None)) fs_configs = cephfs_config.pop('fs', [{'name': 'cephfs'}]) # wait for standbys to become available (slow due to valgrind, perhaps) diff --git a/qa/tasks/cephadm.py b/qa/tasks/cephadm.py index daf26c61721..ea39deddc1f 100644 --- a/qa/tasks/cephadm.py +++ b/qa/tasks/cephadm.py @@ -1253,6 +1253,8 @@ def cephfs_setup(ctx, config): if len(mdss) > 0: log.info('Setting up CephFS filesystem(s)...') cephfs_config = config.get('cephfs', {}) + ctx.cephfs_config = deepcopy(cephfs_config) + ctx.subvols = deepcopy(config.get('subvols', None)) fs_configs = cephfs_config.pop('fs', [{'name': 'cephfs'}]) set_allow_multifs = len(fs_configs) > 1 diff --git a/qa/tasks/cephfs/filesystem.py b/qa/tasks/cephfs/filesystem.py index 1533df52cdf..402f25dcd71 100644 --- a/qa/tasks/cephfs/filesystem.py +++ b/qa/tasks/cephfs/filesystem.py @@ -9,6 +9,7 @@ import re import errno import random +from copy import deepcopy from io import BytesIO, StringIO from errno import EBUSY @@ -561,7 +562,34 @@ class FilesystemBase(MDSClusterBase): self.data_pool_name = None self.data_pools = None self.fs_config = fs_config - self.ec_profile = fs_config.get('ec_profile') + if self.fs_config: + log.debug(f"Filesystem init - using passed config={self.fs_config} for fsname={self.name}") + elif self.name: + # Construct fs_config from config stored in context. + log.debug(f"Filesystem init - using context cephfs_config={ctx.cephfs_config} for fsname={self.name}") + log.debug(f"Filesystem init - using context subvols={ctx.subvols} for fsname={self.name}") + # There are generic fs options which should apply to all the filesystems and each + # filesystem can have extra options or can override the generic ones. The + # temp_cephfs_config has generic fs options and the fs_configs has fs specific options + # after it's popped from temp_cephfs_config. The for loop iterates through fs specific + # option and merges them with generic fs option and construct the final list for the + # particular fs. + temp_cephfs_config = deepcopy(ctx.cephfs_config) + subvols = deepcopy(ctx.subvols) + fs_configs = temp_cephfs_config.pop('fs', [{'name': 'cephfs'}]) + for fs_conf in fs_configs: + assert isinstance(fs_conf, dict) + fs_name = fs_conf.pop('name') + if fs_name == self.name: + misc.deep_merge(temp_cephfs_config, fs_conf) + if subvols: + misc.deep_merge(temp_cephfs_config, {'subvols': subvols}) + self.fs_config = temp_cephfs_config + log.debug(f"Filesystem init - constructed from context - cephfs_config {self.fs_config} for {self.name}") + else: + log.debug("Filesystem init - no fs_config and fsname - instance is not used for fs create") + + self.ec_profile = self.fs_config.get('ec_profile') client_list = list(misc.all_roles_of_type(self._ctx.cluster, 'client')) self.client_id = client_list[0]