Skip to content

Commit

Permalink
qa: enhancement for subvol creation and mounting
Browse files Browse the repository at this point in the history
Fixes: https://tracker.ceph.com/issues/54317
Signed-off-by: Milind Changire <mchangir@redhat.com>
  • Loading branch information
mchangir committed Apr 7, 2022
1 parent 81bb0ec commit bf83eaa
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 4 deletions.
3 changes: 3 additions & 0 deletions qa/tasks/ceph.py
Expand Up @@ -444,6 +444,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)
fss.append(fs)

Expand Down
14 changes: 14 additions & 0 deletions qa/tasks/ceph_fuse.py
Expand Up @@ -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
"""
Expand Down
3 changes: 3 additions & 0 deletions qa/tasks/cephadm.py
Expand Up @@ -890,6 +890,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()
Expand Down
29 changes: 29 additions & 0 deletions qa/tasks/cephfs/filesystem.py
Expand Up @@ -699,6 +699,7 @@ def create(self):
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)
Expand All @@ -711,6 +712,34 @@ def create(self):
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
Expand Down
8 changes: 6 additions & 2 deletions qa/tasks/cephfs/fuse_mount.py
Expand Up @@ -113,8 +113,12 @@ def _get_mount_cmd(self, mntopts):
mount_cmd += ['--id', self.client_id]
if self.client_keyring_path and self.client_id:
mount_cmd += ['-k', self.client_keyring_path]
if self.cephfs_mntpt:
mount_cmd += ["--client_mountpoint=" + self.cephfs_mntpt]

self.validate_subvol_options()

assert(self.cephfs_mntpt)
mount_cmd += ["--client_mountpoint=" + self.cephfs_mntpt]

if self.cephfs_name:
mount_cmd += ["--client_fs=" + self.cephfs_name]
if mntopts:
Expand Down
6 changes: 4 additions & 2 deletions qa/tasks/cephfs/kernel_mount.py
Expand Up @@ -44,8 +44,6 @@ def mount(self, mntopts=[], check_status=True, **kwargs):

self.setup_netns()

if not self.cephfs_mntpt:
self.cephfs_mntpt = '/'
if not self.cephfs_name:
self.cephfs_name = 'cephfs'

Expand Down Expand Up @@ -85,6 +83,10 @@ def _run_mount_cmd(self, mntopts, check_status):
def _make_mount_cmd_old_or_new_style(self):
optd = {}
mnt_stx = ''

self.validate_subvol_options()

assert(self.cephfs_mntpt)
if self.syntax_style == 'v1':
mnt_stx = f':{self.cephfs_mntpt}'
if self.client_id:
Expand Down
19 changes: 19 additions & 0 deletions qa/tasks/cephfs/mount.py
Expand Up @@ -1351,3 +1351,22 @@ def dir_checksum(self, path=None, follow_symlinks=False):
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 = "/"

0 comments on commit bf83eaa

Please sign in to comment.