From 72b3417890858138f8744e822d382082fcb1119d Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 17 Jul 2014 21:35:22 +0100 Subject: [PATCH] task/mds_journal_migration: use existing clients Since refactoring ceph_fuse and kclient tasks to store Mount objects on ctx, the mds_journal_migration task can use those instead of explicitly instantiating its own. Signed-off-by: John Spray --- teuthology/task/cephfs/kernel_mount.py | 16 +++++++++++++ teuthology/task/cephfs/mount.py | 18 ++++++++++++++- teuthology/task/mds_journal_migration.py | 29 ++++++++++++++++-------- 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/teuthology/task/cephfs/kernel_mount.py b/teuthology/task/cephfs/kernel_mount.py index 6e47bb45ca..c319084697 100644 --- a/teuthology/task/cephfs/kernel_mount.py +++ b/teuthology/task/cephfs/kernel_mount.py @@ -80,3 +80,19 @@ class KernelMount(CephFSMount): mnt, ], ) + + def cleanup(self): + pass + + def umount_wait(self): + pass + + def is_mounted(self): + return True + + def wait_until_mounted(self): + pass + + def teardown(self): + super(KernelMount, self).teardown() + self.umount() diff --git a/teuthology/task/cephfs/mount.py b/teuthology/task/cephfs/mount.py index bb8a6caa14..42b943db37 100644 --- a/teuthology/task/cephfs/mount.py +++ b/teuthology/task/cephfs/mount.py @@ -1,4 +1,4 @@ - +from contextlib import contextmanager import logging import datetime from textwrap import dedent @@ -47,6 +47,22 @@ class CephFSMount(object): def cleanup(self): raise NotImplementedError() + def wait_until_mounted(self): + raise NotImplementedError() + + @contextmanager + def mounted(self): + """ + A context manager, from an initially unmounted state, to mount + this, yield, and then unmount and clean up. + """ + self.mount() + self.wait_until_mounted() + try: + yield + finally: + self.umount_wait() + def create_files(self): assert(self.is_mounted()) diff --git a/teuthology/task/mds_journal_migration.py b/teuthology/task/mds_journal_migration.py index 090c10d47b..53ee53e0cf 100644 --- a/teuthology/task/mds_journal_migration.py +++ b/teuthology/task/mds_journal_migration.py @@ -4,7 +4,6 @@ import logging from teuthology import misc from teuthology.task.ceph import write_conf -from teuthology.task.ceph_fuse import task as ceph_fuse_ctx from teuthology.task.cephfs.filesystem import Filesystem log = logging.getLogger(__name__) @@ -28,6 +27,13 @@ def task(ctx, config): client: client.0 """ + if not hasattr(ctx, 'ceph'): + raise RuntimeError("This task must be nested in 'ceph' task") + + if not hasattr(ctx, 'mounts'): + raise RuntimeError("This task must be nested inside 'kclient' or 'ceph_fuse' task") + + # Determine which client we will use if config and 'client' in config: # Use client specified in config client_role = config['client'] @@ -43,17 +49,13 @@ def task(ctx, config): client_id = client_list[0] except IndexError: raise RuntimeError("This task requires at least one client") - else: - client_role = "client.{0}".format(client_id) fs = Filesystem(ctx, config) + ctx.fs = fs old_journal_version = JOURNAL_FORMAT_LEGACY new_journal_version = JOURNAL_FORMAT_RESILIENT # Set config so that journal will be created in older format - if not hasattr(ctx, 'ceph'): - raise RuntimeError("This task must be nested in 'ceph' task") - if 'mds' not in ctx.ceph.conf: ctx.ceph.conf['mds'] = {} ctx.ceph.conf['mds']['mds journal format'] = old_journal_version @@ -61,13 +63,15 @@ def task(ctx, config): # used a different config path this won't work. # Create a filesystem using the older journal format. + for mount in ctx.mounts.values(): + mount.umount_wait() fs.mds_stop() fs.reset() fs.mds_restart() # Do some client work so that the log is populated with something. - with ceph_fuse_ctx(ctx, [client_role]) as client_mounts: - mount = client_mounts[client_id] + mount = ctx.mounts[client_id] + with mount.mounted(): mount.create_files() mount.check_files() # sanity, this should always pass @@ -80,8 +84,7 @@ def task(ctx, config): # Check that files created in the initial client workload are still visible # in a client mount. - with ceph_fuse_ctx(ctx, [client_role]) as client_mounts: - mount = client_mounts[client_id] + with mount.mounted(): mount.check_files() # Verify that the journal really has been rewritten. @@ -91,4 +94,10 @@ def task(ctx, config): new_journal_version, journal_version() )) + # Check that all MDS daemons are still up and running an in expected state + + # Leave all MDSs and clients running for any child tasks + for mount in ctx.mounts.values(): + mount.mount() + yield -- 2.39.5