]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/kclient.py
2 Mount/unmount a ``kernel`` client.
7 from teuthology
.misc
import deep_merge
8 from teuthology
.orchestra
.run
import CommandFailedError
9 from teuthology
import misc
10 from teuthology
.contextutil
import MaxWhileTries
11 from cephfs
.kernel_mount
import KernelMount
13 log
= logging
.getLogger(__name__
)
15 @contextlib.contextmanager
16 def task(ctx
, config
):
18 Mount/unmount a ``kernel`` client.
20 The config is optional and defaults to mounting on all clients. If
21 a config is given, it is expected to be a list of clients to do
22 this operation on. This lets you e.g. set up one client with
23 ``ceph-fuse`` and another with ``kclient``.
25 Example that mounts all clients::
32 Example that uses both ``kclient` and ``ceph-fuse``::
36 - ceph-fuse: [client.0]
41 Pass a dictionary instead of lists to specify per-client config:
49 :param config: Configuration
51 log
.info('Mounting kernel clients...')
52 assert config
is None or isinstance(config
, list) or isinstance(config
, dict), \
53 "task kclient got invalid config"
56 config
= ['client.{id}'.format(id=id_
)
57 for id_
in misc
.all_roles_of_type(ctx
.cluster
, 'client')]
59 if isinstance(config
, list):
61 config
= dict([r
, dict()] for r
in client_roles
)
62 elif isinstance(config
, dict):
63 client_roles
= filter(lambda x
: 'client.' in x
, config
.keys())
65 raise ValueError("Invalid config object: {0} ({1})".format(config
, config
.__class
__))
67 # config has been converted to a dict by this point
68 overrides
= ctx
.config
.get('overrides', {})
69 deep_merge(config
, overrides
.get('kclient', {}))
71 clients
= list(misc
.get_clients(ctx
=ctx
, roles
=client_roles
))
73 test_dir
= misc
.get_testdir(ctx
)
76 for id_
, remote
in clients
:
77 client_config
= config
.get("client.%s" % id_
)
78 if client_config
is None:
81 if config
.get("disabled", False) or not client_config
.get('mounted', True):
84 kernel_mount
= KernelMount(
89 ctx
.teuthology_config
.get('ipmi_user', None),
90 ctx
.teuthology_config
.get('ipmi_password', None),
91 ctx
.teuthology_config
.get('ipmi_domain', None)
94 mounts
[id_
] = kernel_mount
96 if client_config
.get('debug', False):
97 remote
.run(args
=["sudo", "bash", "-c", "echo 'module ceph +p' > /sys/kernel/debug/dynamic_debug/control"])
98 remote
.run(args
=["sudo", "bash", "-c", "echo 'module libceph +p' > /sys/kernel/debug/dynamic_debug/control"])
104 log
.info('Unmounting kernel clients...')
107 for mount
in mounts
.values():
108 if mount
.is_mounted():
111 except (CommandFailedError
, MaxWhileTries
):
112 log
.warn("Ordinary umount failed, forcing...")
114 mount
.umount_wait(force
=True)
122 umount_all() # ignore forced retval, we are already in error handling
125 forced
= umount_all()
127 # The context managers within the kclient manager worked (i.e.
128 # the test workload passed) but for some reason we couldn't
129 # umount, so turn this into a test failure.
130 raise RuntimeError("Kernel mounts did not umount cleanly")