]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/ceph_fuse.py
8 from teuthology
import misc
9 from tasks
.cephfs
.fuse_mount
import FuseMount
11 log
= logging
.getLogger(__name__
)
14 @contextlib.contextmanager
15 def task(ctx
, config
):
17 Mount/unmount a ``ceph-fuse`` client.
19 The config is optional and defaults to mounting on all clients. If
20 a config is given, it is expected to be a list of clients to do
21 this operation on. This lets you e.g. set up one client with
22 ``ceph-fuse`` and another with ``kclient``.
24 ``brxnet`` should be a Private IPv4 Address range, default range is
27 Example that mounts all clients::
33 - brxnet: [192.168.0.0/16]
35 Example that uses both ``kclient` and ``ceph-fuse``::
39 - ceph-fuse: [client.0]
43 Example that enables valgrind:
49 valgrind: [--tool=memcheck, --leak-check=full, --show-reachable=yes]
52 Example that stops an already-mounted client:
58 - ceph-fuse: [client.0]
59 - ... do something that requires the FS mounted ...
63 - ... do something that requires the FS unmounted ...
65 Example that adds more generous wait time for mount (for virtual machines):
71 mount_wait: 60 # default is 0, do not wait before checking /sys/
72 mount_timeout: 120 # default is 30, give up if /sys/ is not populated
75 Example that creates and mounts a subvol:
81 subvol_options: "--namespace-isolated --size 25000000000"
90 :param config: Configuration
92 log
.info('Running ceph_fuse task...')
95 ids
= misc
.all_roles_of_type(ctx
.cluster
, 'client')
96 client_roles
= [f
'client.{id_}' for id_
in ids
]
97 config
= dict([r
, dict()] for r
in client_roles
)
98 elif isinstance(config
, list):
100 config
= dict([r
, dict()] for r
in client_roles
)
101 elif isinstance(config
, dict):
102 client_roles
= filter(lambda x
: 'client.' in x
, config
.keys())
104 raise ValueError(f
"Invalid config object: {config} ({config.__class__})")
105 log
.info(f
"config is {config}")
107 clients
= list(misc
.get_clients(ctx
=ctx
, roles
=client_roles
))
108 testdir
= misc
.get_testdir(ctx
)
109 all_mounts
= getattr(ctx
, 'mounts', {})
114 brxnet
= config
.get("brxnet", None)
116 # Construct any new FuseMount instances
117 overrides
= ctx
.config
.get('overrides', {}).get('ceph-fuse', {})
118 top_overrides
= dict(filter(lambda x
: 'client.' not in x
[0], overrides
.items()))
119 for id_
, remote
in clients
:
120 entity
= f
"client.{id_}"
121 client_config
= config
.get(entity
)
122 if client_config
is None:
124 # top level overrides
125 misc
.deep_merge(client_config
, top_overrides
)
126 # mount specific overrides
127 client_config_overrides
= overrides
.get(entity
)
128 misc
.deep_merge(client_config
, client_config_overrides
)
129 log
.info(f
"{entity} config is {client_config}")
132 auth_id
= client_config
.get("auth_id", id_
)
133 cephfs_name
= client_config
.get("cephfs_name")
135 skip
= client_config
.get("skip", False)
140 if id_
not in all_mounts
:
141 fuse_mount
= FuseMount(ctx
=ctx
, client_config
=client_config
,
142 test_dir
=testdir
, client_id
=auth_id
,
143 client_remote
=remote
, brxnet
=brxnet
,
144 cephfs_name
=cephfs_name
)
145 all_mounts
[id_
] = fuse_mount
147 # Catch bad configs where someone has e.g. tried to use ceph-fuse and kcephfs for the same client
148 assert isinstance(all_mounts
[id_
], FuseMount
)
150 if not config
.get("disabled", False) and client_config
.get('mounted', True):
151 mounted_by_me
[id_
] = {"config": client_config
, "mount": all_mounts
[id_
]}
153 ctx
.mounts
= all_mounts
155 # Umount any pre-existing clients that we have not been asked to mount
156 for client_id
in set(all_mounts
.keys()) - set(mounted_by_me
.keys()) - set(skipped
.keys()):
157 mount
= all_mounts
[client_id
]
158 if mount
.is_mounted():
161 for remote
in remotes
:
162 FuseMount
.cleanup_stale_netnses_and_bridge(remote
)
164 # Mount any clients we have been asked to (default to mount all)
165 log
.info('Mounting ceph-fuse clients...')
166 for info
in mounted_by_me
.values():
167 config
= info
["config"]
168 mount_x
= info
['mount']
169 mount_x
.mount(mntopts
=config
.get('mntopts', []), mntargs
=config
.get('mntargs', []))
171 for info
in mounted_by_me
.values():
172 info
["mount"].wait_until_mounted()
177 log
.info('Unmounting ceph-fuse clients...')
179 for info
in mounted_by_me
.values():
180 # Conditional because an inner context might have umounted it
181 mount
= info
["mount"]
182 if mount
.is_mounted():
184 for remote
in remotes
:
185 FuseMount
.cleanup_stale_netnses_and_bridge(remote
)