]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | """ |
2 | Task for running rbd mirroring daemons and configuring mirroring | |
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 | |
f67539c2 | 11 | from tasks.ceph_manager import get_valgrind_args |
e306af50 | 12 | from tasks.util import get_remote_for_role |
7c673cae FG |
13 | |
14 | log = logging.getLogger(__name__) | |
15 | ||
16 | ||
17 | class RBDMirror(Task): | |
18 | """ | |
19 | Run an rbd-mirror daemon to sync rbd images between clusters. | |
20 | ||
21 | This requires two clients (one from each cluster) on the same host | |
22 | to connect with. The pool configuration should be adjusted by later | |
23 | test scripts to include the remote client and cluster name. This task | |
24 | just needs to know how to connect to the local cluster. | |
25 | ||
26 | For example: | |
27 | ||
28 | roles: | |
29 | - [primary.mon.a, primary.osd.0, primary.osd.1, primary.osd.2] | |
30 | - [secondary.mon.a, secondary.osd.0, secondary.osd.1, secondary.osd.2] | |
31 | - [primary.client.mirror, secondary.client.mirror] | |
32 | tasks: | |
33 | - ceph: | |
34 | cluster: primary | |
35 | - ceph: | |
36 | cluster: secondary | |
37 | - rbd-mirror: | |
38 | client: primary.client.mirror | |
39 | ||
40 | To mirror back to the primary cluster as well, add another | |
41 | rbd_mirror instance: | |
42 | ||
43 | - rbd-mirror: | |
44 | client: secondary.client.mirror | |
45 | ||
46 | Possible options for this task are: | |
47 | ||
48 | client: role - ceph client to connect as | |
49 | valgrind: [--tool=<valgrind tool>] - none by default | |
50 | coverage: bool - whether this run may be collecting coverage data | |
11fdf7f2 | 51 | thrash: bool - whether this run may be thrashed |
7c673cae FG |
52 | """ |
53 | def __init__(self, ctx, config): | |
54 | super(RBDMirror, self).__init__(ctx, config) | |
55 | self.log = log | |
56 | ||
57 | def setup(self): | |
58 | super(RBDMirror, self).setup() | |
59 | try: | |
60 | self.client = self.config['client'] | |
61 | except KeyError: | |
62 | raise ConfigError('rbd-mirror requires a client to connect with') | |
63 | ||
64 | self.cluster_name, type_, self.client_id = misc.split_role(self.client) | |
65 | ||
66 | if type_ != 'client': | |
67 | msg = 'client role ({0}) must be a client'.format(self.client) | |
68 | raise ConfigError(msg) | |
69 | ||
70 | self.remote = get_remote_for_role(self.ctx, self.client) | |
71 | ||
72 | def begin(self): | |
73 | super(RBDMirror, self).begin() | |
74 | testdir = misc.get_testdir(self.ctx) | |
75 | daemon_signal = 'kill' | |
11fdf7f2 TL |
76 | if 'coverage' in self.config or 'valgrind' in self.config or \ |
77 | self.config.get('thrash', False): | |
7c673cae FG |
78 | daemon_signal = 'term' |
79 | ||
80 | args = [ | |
81 | 'adjust-ulimits', | |
82 | 'ceph-coverage', | |
83 | '{tdir}/archive/coverage'.format(tdir=testdir), | |
84 | 'daemon-helper', | |
85 | daemon_signal, | |
86 | ] | |
87 | ||
88 | if 'valgrind' in self.config: | |
f67539c2 | 89 | args = get_valgrind_args( |
7c673cae FG |
90 | testdir, |
91 | 'rbd-mirror-{id}'.format(id=self.client), | |
92 | args, | |
93 | self.config.get('valgrind') | |
94 | ) | |
95 | ||
96 | args.extend([ | |
224ce89b | 97 | 'rbd-mirror', '--foreground', |
7c673cae FG |
98 | '--cluster', |
99 | self.cluster_name, | |
100 | '--id', | |
101 | self.client_id, | |
102 | ]) | |
103 | ||
104 | self.ctx.daemons.add_daemon( | |
105 | self.remote, 'rbd-mirror', self.client, | |
106 | cluster=self.cluster_name, | |
107 | args=args, | |
108 | logger=self.log.getChild(self.client), | |
109 | stdin=run.PIPE, | |
110 | wait=False, | |
111 | ) | |
112 | ||
113 | def end(self): | |
114 | mirror_daemon = self.ctx.daemons.get_daemon('rbd-mirror', | |
115 | self.client, | |
116 | self.cluster_name) | |
117 | mirror_daemon.stop() | |
118 | super(RBDMirror, self).end() | |
119 | ||
120 | task = RBDMirror |