]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | """ |
2 | Task for running cephfs mirror daemons | |
3 | """ | |
4 | ||
5 | import logging | |
6 | ||
7 | from teuthology.orchestra import run | |
8 | from teuthology import misc | |
9 | from teuthology.exceptions import ConfigError | |
10 | from teuthology.task import Task | |
11 | from tasks.ceph_manager import get_valgrind_args | |
12 | from tasks.util import get_remote_for_role | |
13 | ||
14 | log = logging.getLogger(__name__) | |
15 | ||
16 | class CephFSMirror(Task): | |
17 | def __init__(self, ctx, config): | |
18 | super(CephFSMirror, self).__init__(ctx, config) | |
19 | self.log = log | |
20 | ||
21 | def setup(self): | |
22 | super(CephFSMirror, self).setup() | |
23 | try: | |
24 | self.client = self.config['client'] | |
25 | except KeyError: | |
26 | raise ConfigError('cephfs-mirror requires a client to connect') | |
27 | ||
28 | self.cluster_name, type_, self.client_id = misc.split_role(self.client) | |
29 | if not type_ == 'client': | |
30 | raise ConfigError(f'client role {self.client} must be a client') | |
31 | self.remote = get_remote_for_role(self.ctx, self.client) | |
32 | ||
33 | def begin(self): | |
34 | super(CephFSMirror, self).begin() | |
35 | testdir = misc.get_testdir(self.ctx) | |
36 | ||
37 | args = [ | |
38 | 'adjust-ulimits', | |
39 | 'ceph-coverage', | |
40 | '{tdir}/archive/coverage'.format(tdir=testdir), | |
41 | 'daemon-helper', | |
42 | 'term', | |
43 | ] | |
44 | ||
45 | if 'valgrind' in self.config: | |
46 | args = get_valgrind_args( | |
47 | testdir, 'cephfs-mirror-{id}'.format(id=self.client), | |
48 | args, self.config.get('valgrind')) | |
49 | ||
50 | args.extend([ | |
51 | 'cephfs-mirror', | |
52 | '--cluster', | |
53 | self.cluster_name, | |
54 | '--id', | |
55 | self.client_id, | |
56 | ]) | |
a4b75251 TL |
57 | if 'run_in_foreground' in self.config: |
58 | args.extend(['--foreground']) | |
f67539c2 TL |
59 | |
60 | self.ctx.daemons.add_daemon( | |
61 | self.remote, 'cephfs-mirror', self.client, | |
62 | args=args, | |
63 | logger=self.log.getChild(self.client), | |
64 | stdin=run.PIPE, | |
65 | wait=False, | |
66 | ) | |
67 | ||
68 | def end(self): | |
69 | mirror_daemon = self.ctx.daemons.get_daemon('cephfs-mirror', self.client) | |
70 | mirror_daemon.stop() | |
71 | super(CephFSMirror, self).end() | |
72 | ||
73 | task = CephFSMirror |