]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/ceph_fuse.py
8 from teuthology
import misc
as teuthology
9 from cephfs
.fuse_mount
import FuseMount
10 from tasks
.cephfs
.filesystem
import MDSCluster
11 from tasks
.cephfs
.filesystem
import Filesystem
13 log
= logging
.getLogger(__name__
)
16 def get_client_configs(ctx
, config
):
18 Get a map of the configuration for each FUSE client in the configuration by
19 combining the configuration of the current task with any global overrides.
21 :param ctx: Context instance
22 :param config: configuration for this task
23 :return: dict of client name to config or to None
26 config
= dict(('client.{id}'.format(id=id_
), None)
27 for id_
in teuthology
.all_roles_of_type(ctx
.cluster
, 'client'))
28 elif isinstance(config
, list):
29 config
= dict((name
, None) for name
in config
)
31 overrides
= ctx
.config
.get('overrides', {})
32 teuthology
.deep_merge(config
, overrides
.get('ceph-fuse', {}))
37 @contextlib.contextmanager
38 def task(ctx
, config
):
40 Mount/unmount a ``ceph-fuse`` client.
42 The config is optional and defaults to mounting on all clients. If
43 a config is given, it is expected to be a list of clients to do
44 this operation on. This lets you e.g. set up one client with
45 ``ceph-fuse`` and another with ``kclient``.
47 Example that mounts all clients::
54 Example that uses both ``kclient` and ``ceph-fuse``::
58 - ceph-fuse: [client.0]
62 Example that enables valgrind:
68 valgrind: [--tool=memcheck, --leak-check=full, --show-reachable=yes]
71 Example that stops an already-mounted client:
77 - ceph-fuse: [client.0]
78 - ... do something that requires the FS mounted ...
82 - ... do something that requires the FS unmounted ...
84 Example that adds more generous wait time for mount (for virtual machines):
90 mount_wait: 60 # default is 0, do not wait before checking /sys/
91 mount_timeout: 120 # default is 30, give up if /sys/ is not populated
95 :param config: Configuration
97 log
.info('Mounting ceph-fuse clients...')
99 testdir
= teuthology
.get_testdir(ctx
)
100 config
= get_client_configs(ctx
, config
)
102 # List clients we will configure mounts for, default is all clients
103 clients
= list(teuthology
.get_clients(ctx
=ctx
, roles
=filter(lambda x
: 'client.' in x
, config
.keys())))
105 all_mounts
= getattr(ctx
, 'mounts', {})
108 log
.info('Wait for MDS to reach steady state...')
109 mds_cluster
= MDSCluster(ctx
)
110 status
= mds_cluster
.status()
111 for filesystem
in status
.get_filesystems():
112 fs
= Filesystem(ctx
, fscid
=filesystem
['id'])
113 fs
.wait_for_daemons()
114 log
.info('Ready to start ceph-fuse...')
116 # Construct any new FuseMount instances
117 for id_
, remote
in clients
:
118 client_config
= config
.get("client.%s" % id_
)
119 if client_config
is None:
122 if id_
not in all_mounts
:
123 fuse_mount
= FuseMount(client_config
, testdir
, id_
, remote
)
124 all_mounts
[id_
] = fuse_mount
126 # Catch bad configs where someone has e.g. tried to use ceph-fuse and kcephfs for the same client
127 assert isinstance(all_mounts
[id_
], FuseMount
)
129 if not config
.get("disabled", False) and client_config
.get('mounted', True):
130 mounted_by_me
[id_
] = all_mounts
[id_
]
132 ctx
.mounts
= all_mounts
134 # Mount any clients we have been asked to (default to mount all)
135 for mount
in mounted_by_me
.values():
138 for mount
in mounted_by_me
.values():
139 mount
.wait_until_mounted()
141 # Umount any pre-existing clients that we have not been asked to mount
142 for client_id
in set(all_mounts
.keys()) - set(mounted_by_me
.keys()):
143 mount
= all_mounts
[client_id
]
144 if mount
.is_mounted():
150 log
.info('Unmounting ceph-fuse clients...')
152 for mount
in mounted_by_me
.values():
153 # Conditional because an inner context might have umounted it
154 if mount
.is_mounted():