]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa: Honor cephfs config from yaml across test cases
authorKotresh HR <khiremat@redhat.com>
Wed, 11 Jun 2025 07:04:04 +0000 (12:34 +0530)
committerKotresh HR <khiremat@redhat.com>
Tue, 5 Aug 2025 06:26:29 +0000 (06:26 +0000)
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 <khiremat@redhat.com>
qa/tasks/ceph.py
qa/tasks/cephadm.py
qa/tasks/cephfs/filesystem.py

index af55c9a1b2bc96da10d7fd0552649f741f8be9cb..3288e53d3b2063291383ad39b2688345d2dbe069 100644 (file)
@@ -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)
index daf26c617219fa464cfae36aa3a9af4e1a6c35fc..ea39deddc1f7dcd87c83e42c527f960baaceb988 100644 (file)
@@ -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
 
index 1533df52cdfe19000530f57749e2f8df5baebc3c..402f25dcd7151b12e4c5acaa0d69ff9accaef61c 100644 (file)
@@ -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]