From f8b939e128e54af4453dce6c21d06218c4c29406 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Wed, 10 Nov 2021 23:15:41 -0500 Subject: [PATCH] test: mount kclient using new-style (v2) syntax But, do not throw away the old style mount syntax since we would want to continue testing it since users (scripts) might still be using it. Signed-off-by: Venky Shankar --- qa/cephfs/mount/kclient/mount-syntax/$ | 0 qa/cephfs/mount/kclient/mount-syntax/v1.yaml | 3 ++ qa/cephfs/mount/kclient/mount-syntax/v2.yaml | 3 ++ qa/tasks/cephfs/kernel_mount.py | 37 +++++++++++++++----- 4 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 qa/cephfs/mount/kclient/mount-syntax/$ create mode 100644 qa/cephfs/mount/kclient/mount-syntax/v1.yaml create mode 100644 qa/cephfs/mount/kclient/mount-syntax/v2.yaml diff --git a/qa/cephfs/mount/kclient/mount-syntax/$ b/qa/cephfs/mount/kclient/mount-syntax/$ new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/qa/cephfs/mount/kclient/mount-syntax/v1.yaml b/qa/cephfs/mount/kclient/mount-syntax/v1.yaml new file mode 100644 index 0000000000000..84d5d43b2570b --- /dev/null +++ b/qa/cephfs/mount/kclient/mount-syntax/v1.yaml @@ -0,0 +1,3 @@ +overrides: + kclient: + syntax: 'v1' diff --git a/qa/cephfs/mount/kclient/mount-syntax/v2.yaml b/qa/cephfs/mount/kclient/mount-syntax/v2.yaml new file mode 100644 index 0000000000000..ef7d304244807 --- /dev/null +++ b/qa/cephfs/mount/kclient/mount-syntax/v2.yaml @@ -0,0 +1,3 @@ +overrides: + kclient: + syntax: 'v2' diff --git a/qa/tasks/cephfs/kernel_mount.py b/qa/tasks/cephfs/kernel_mount.py index d8566d7534cc9..ba1ad0f0d1da5 100644 --- a/qa/tasks/cephfs/kernel_mount.py +++ b/qa/tasks/cephfs/kernel_mount.py @@ -30,6 +30,7 @@ class KernelMount(CephFSMount): self.dynamic_debug = config.get('dynamic_debug', False) self.rbytes = config.get('rbytes', False) + self.syntax_style = config.get('syntax', 'v2') self.inst = None self.addr = None self._mount_bin = ['adjust-ulimits', 'ceph-coverage', self.test_dir +\ @@ -43,6 +44,8 @@ class KernelMount(CephFSMount): if not self.cephfs_mntpt: self.cephfs_mntpt = '/' + if not self.cephfs_name: + self.cephfs_name = 'cephfs' self._create_mntpt() @@ -77,28 +80,44 @@ class KernelMount(CephFSMount): mountcmd_stderr.getvalue()) log.info('mount command passed') + def _make_mount_cmd_old_or_new_style(self): + optd = {} + mnt_stx = '' + if self.syntax_style == 'v1': + mnt_stx = f':{self.cephfs_mntpt}' + if self.client_id: + optd['name'] = self.client_id + if self.cephfs_name: + optd['mds_namespace'] = self.cephfs_name + elif self.syntax_style == 'v2': + mnt_stx = f'{self.client_id}@.{self.cephfs_name}={self.cephfs_mntpt}' + else: + assert 0, f'invalid syntax style: {self.syntax_style}' + return (mnt_stx, optd) + def _get_mount_cmd(self, mntopts): opts = 'norequire_active_mds' - if self.client_id: - opts += ',name=' + self.client_id if self.client_keyring_path and self.client_id: opts += ',secret=' + self.get_key_from_keyfile() if self.config_path: opts += ',conf=' + self.config_path - if self.cephfs_name: - opts += ",mds_namespace=" + self.cephfs_name if self.rbytes: opts += ",rbytes" else: opts += ",norbytes" - if mntopts: - opts += ',' + ','.join(mntopts) mount_cmd = ['sudo'] + self._nsenter_args - mount_dev = ':' + self.cephfs_mntpt - mount_cmd += self._mount_bin + [mount_dev, self.hostfs_mntpt, '-v', + stx_opt = self._make_mount_cmd_old_or_new_style() + for opt_name, opt_val in stx_opt[1].items(): + opts += f',{opt_name}={opt_val}' + if mntopts: + opts += ',' + ','.join(mntopts) + log.info(f'mounting using device: {stx_opt[0]}') + # do not fall-back to old-style mount (catch new-style + # mount syntax bugs in the kernel). + opts += ",nofallback" + mount_cmd += self._mount_bin + [stx_opt[0], self.hostfs_mntpt, '-v', '-o', opts] - return mount_cmd def umount(self, force=False): -- 2.39.5