2013-10-12 08:28:27 +00:00
|
|
|
"""
|
|
|
|
Ceph FUSE client task
|
|
|
|
"""
|
2014-07-02 14:38:47 +00:00
|
|
|
|
2011-06-02 22:04:01 +00:00
|
|
|
import contextlib
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from teuthology import misc as teuthology
|
2014-08-07 14:24:59 +00:00
|
|
|
from teuthology.orchestra import run
|
|
|
|
from cephfs.fuse_mount import FuseMount
|
2011-06-02 22:04:01 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2014-07-02 14:38:47 +00:00
|
|
|
|
|
|
|
def get_client_configs(ctx, config):
|
|
|
|
"""
|
|
|
|
Get a map of the configuration for each FUSE client in the configuration
|
|
|
|
by combining the configuration of the current task with any global overrides.
|
|
|
|
|
|
|
|
:param ctx: Context instance
|
|
|
|
:param config: configuration for this task
|
|
|
|
:return: dict of client name to config or to None
|
|
|
|
"""
|
|
|
|
if config is None:
|
|
|
|
config = dict(('client.{id}'.format(id=id_), None)
|
|
|
|
for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client'))
|
|
|
|
elif isinstance(config, list):
|
|
|
|
config = dict((name, None) for name in config)
|
|
|
|
|
|
|
|
overrides = ctx.config.get('overrides', {})
|
|
|
|
teuthology.deep_merge(config, overrides.get('ceph-fuse', {}))
|
|
|
|
|
|
|
|
return config
|
|
|
|
|
|
|
|
|
2011-06-02 22:04:01 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def task(ctx, config):
|
2011-06-06 21:22:49 +00:00
|
|
|
"""
|
2011-09-23 15:57:18 +00:00
|
|
|
Mount/unmount a ``ceph-fuse`` client.
|
2011-06-06 21:22:49 +00:00
|
|
|
|
2011-06-16 23:07:59 +00:00
|
|
|
The config is optional and defaults to mounting on all clients. If
|
|
|
|
a config is given, it is expected to be a list of clients to do
|
|
|
|
this operation on. This lets you e.g. set up one client with
|
2011-09-23 15:57:18 +00:00
|
|
|
``ceph-fuse`` and another with ``kclient``.
|
2011-06-16 23:07:59 +00:00
|
|
|
|
|
|
|
Example that mounts all clients::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
2012-02-20 15:12:53 +00:00
|
|
|
- ceph-fuse:
|
2011-06-16 23:07:59 +00:00
|
|
|
- interactive:
|
|
|
|
|
2012-02-20 15:12:53 +00:00
|
|
|
Example that uses both ``kclient` and ``ceph-fuse``::
|
2011-06-06 21:22:49 +00:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
2012-02-20 15:12:53 +00:00
|
|
|
- ceph-fuse: [client.0]
|
2011-06-16 23:07:59 +00:00
|
|
|
- kclient: [client.1]
|
2011-06-06 21:22:49 +00:00
|
|
|
- interactive:
|
2011-08-24 21:07:11 +00:00
|
|
|
|
|
|
|
Example that enables valgrind:
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
2012-02-20 15:12:53 +00:00
|
|
|
- ceph-fuse:
|
2011-08-24 21:07:11 +00:00
|
|
|
client.0:
|
2012-11-10 16:41:41 +00:00
|
|
|
valgrind: [--tool=memcheck, --leak-check=full, --show-reachable=yes]
|
2011-08-24 21:07:11 +00:00
|
|
|
- interactive:
|
|
|
|
|
2013-10-12 08:28:27 +00:00
|
|
|
:param ctx: Context
|
|
|
|
:param config: Configuration
|
2011-06-06 21:22:49 +00:00
|
|
|
"""
|
2011-09-23 15:57:18 +00:00
|
|
|
log.info('Mounting ceph-fuse clients...')
|
2011-06-02 22:04:01 +00:00
|
|
|
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2014-07-02 14:38:47 +00:00
|
|
|
config = get_client_configs(ctx, config)
|
2012-11-10 16:41:41 +00:00
|
|
|
|
2011-08-24 21:07:11 +00:00
|
|
|
clients = list(teuthology.get_clients(ctx=ctx, roles=config.keys()))
|
2011-06-16 23:07:59 +00:00
|
|
|
|
2014-07-02 15:43:16 +00:00
|
|
|
fuse_mounts = {}
|
2011-06-16 23:07:59 +00:00
|
|
|
for id_, remote in clients:
|
2011-08-24 21:07:11 +00:00
|
|
|
client_config = config.get("client.%s" % id_)
|
|
|
|
if client_config is None:
|
|
|
|
client_config = {}
|
2011-06-02 22:04:01 +00:00
|
|
|
|
2014-07-02 14:38:47 +00:00
|
|
|
fuse_mount = FuseMount(client_config, testdir, id_, remote)
|
2014-07-02 15:43:16 +00:00
|
|
|
fuse_mounts[id_] = fuse_mount
|
2014-07-02 14:38:47 +00:00
|
|
|
|
|
|
|
fuse_mount.mount()
|
|
|
|
|
2014-07-02 15:43:16 +00:00
|
|
|
for mount in fuse_mounts.values():
|
2014-07-02 14:38:47 +00:00
|
|
|
mount.wait_until_mounted()
|
2011-06-02 22:04:01 +00:00
|
|
|
|
2014-07-02 15:43:16 +00:00
|
|
|
ctx.mounts = fuse_mounts
|
2011-06-02 22:04:01 +00:00
|
|
|
try:
|
2014-07-02 15:43:16 +00:00
|
|
|
yield fuse_mounts
|
2011-06-02 22:04:01 +00:00
|
|
|
finally:
|
2011-09-23 15:57:18 +00:00
|
|
|
log.info('Unmounting ceph-fuse clients...')
|
2014-07-02 15:43:16 +00:00
|
|
|
for mount in fuse_mounts.values():
|
2014-07-02 14:38:47 +00:00
|
|
|
mount.umount()
|
|
|
|
|
|
|
|
run.wait([m.fuse_daemon for m in fuse_mounts.values()], timeout=600)
|
|
|
|
|
2014-07-02 15:43:16 +00:00
|
|
|
for mount in fuse_mounts.values():
|
2014-07-02 14:38:47 +00:00
|
|
|
mount.cleanup()
|