]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/ceph_fuse.py
405742891674357855c87a01b81977bda5b2d882
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
76 :param config: Configuration
78 log
.info('Running ceph_fuse task...')
81 ids
= misc
.all_roles_of_type(ctx
.cluster
, 'client')
82 client_roles
= [f
'client.{id_}' for id_
in ids
]
83 config
= dict([r
, dict()] for r
in client_roles
)
84 elif isinstance(config
, list):
86 config
= dict([r
, dict()] for r
in client_roles
)
87 elif isinstance(config
, dict):
88 client_roles
= filter(lambda x
: 'client.' in x
, config
.keys())
90 raise ValueError(f
"Invalid config object: {config} ({config.__class__})")
91 log
.info(f
"config is {config}")
93 clients
= list(misc
.get_clients(ctx
=ctx
, roles
=client_roles
))
94 testdir
= misc
.get_testdir(ctx
)
95 all_mounts
= getattr(ctx
, 'mounts', {})
100 brxnet
= config
.get("brxnet", None)
102 # Construct any new FuseMount instances
103 overrides
= ctx
.config
.get('overrides', {}).get('ceph-fuse', {})
104 top_overrides
= dict(filter(lambda x
: 'client.' not in x
[0], overrides
.items()))
105 for id_
, remote
in clients
:
106 entity
= f
"client.{id_}"
107 client_config
= config
.get(entity
)
108 if client_config
is None:
110 # top level overrides
111 for k
, v
in top_overrides
.items():
114 # mount specific overrides
115 client_config_overrides
= overrides
.get(entity
)
116 misc
.deep_merge(client_config
, client_config_overrides
)
117 log
.info(f
"{entity} config is {client_config}")
120 auth_id
= client_config
.get("auth_id", id_
)
121 cephfs_name
= client_config
.get("cephfs_name")
123 skip
= client_config
.get("skip", False)
128 if id_
not in all_mounts
:
129 fuse_mount
= FuseMount(ctx
=ctx
, client_config
=client_config
,
130 test_dir
=testdir
, client_id
=auth_id
,
131 client_remote
=remote
, brxnet
=brxnet
,
132 cephfs_name
=cephfs_name
)
133 all_mounts
[id_
] = fuse_mount
135 # Catch bad configs where someone has e.g. tried to use ceph-fuse and kcephfs for the same client
136 assert isinstance(all_mounts
[id_
], FuseMount
)
138 if not config
.get("disabled", False) and client_config
.get('mounted', True):
139 mounted_by_me
[id_
] = {"config": client_config
, "mount": all_mounts
[id_
]}
141 ctx
.mounts
= all_mounts
143 # Umount any pre-existing clients that we have not been asked to mount
144 for client_id
in set(all_mounts
.keys()) - set(mounted_by_me
.keys()) - set(skipped
.keys()):
145 mount
= all_mounts
[client_id
]
146 if mount
.is_mounted():
149 for remote
in remotes
:
150 FuseMount
.cleanup_stale_netnses_and_bridge(remote
)
152 # Mount any clients we have been asked to (default to mount all)
153 log
.info('Mounting ceph-fuse clients...')
154 for info
in mounted_by_me
.values():
155 config
= info
["config"]
156 mount_x
= info
['mount']
157 if config
.get("mount_path"):
158 mount_x
.cephfs_mntpt
= config
.get("mount_path")
159 if config
.get("mountpoint"):
160 mount_x
.hostfs_mntpt
= config
.get("mountpoint")
161 mount_x
.mount(createfs
=False)
163 for info
in mounted_by_me
.values():
164 info
["mount"].wait_until_mounted()
169 log
.info('Unmounting ceph-fuse clients...')
171 for info
in mounted_by_me
.values():
172 # Conditional because an inner context might have umounted it
173 mount
= info
["mount"]
174 if mount
.is_mounted():
176 for remote
in remotes
:
177 FuseMount
.cleanup_stale_netnses_and_bridge(remote
)