]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | """ |
2 | Special case divergence test with ceph-objectstore-tool export/remove/import | |
3 | """ | |
4 | import logging | |
5 | import time | |
7c673cae | 6 | |
9f95a23c | 7 | from teuthology.exceptions import CommandFailedError |
7c673cae FG |
8 | from teuthology import misc as teuthology |
9 | from util.rados import rados | |
10 | import os | |
11 | ||
12 | ||
13 | log = logging.getLogger(__name__) | |
14 | ||
15 | ||
16 | def task(ctx, config): | |
17 | """ | |
18 | Test handling of divergent entries with prior_version | |
19 | prior to log_tail and a ceph-objectstore-tool export/import | |
20 | ||
21 | overrides: | |
22 | ceph: | |
23 | conf: | |
24 | osd: | |
25 | debug osd: 5 | |
26 | ||
27 | Requires 3 osds on a single test node. | |
28 | """ | |
29 | if config is None: | |
30 | config = {} | |
31 | assert isinstance(config, dict), \ | |
32 | 'divergent_priors task only accepts a dict for configuration' | |
33 | ||
34 | manager = ctx.managers['ceph'] | |
35 | ||
36 | while len(manager.get_osd_status()['up']) < 3: | |
37 | time.sleep(10) | |
31f18b77 | 38 | manager.flush_pg_stats([0, 1, 2]) |
7c673cae FG |
39 | manager.raw_cluster_cmd('osd', 'set', 'noout') |
40 | manager.raw_cluster_cmd('osd', 'set', 'noin') | |
41 | manager.raw_cluster_cmd('osd', 'set', 'nodown') | |
42 | manager.wait_for_clean() | |
43 | ||
44 | # something that is always there | |
45 | dummyfile = '/etc/fstab' | |
46 | dummyfile2 = '/etc/resolv.conf' | |
47 | testdir = teuthology.get_testdir(ctx) | |
48 | ||
49 | # create 1 pg pool | |
50 | log.info('creating foo') | |
51 | manager.raw_cluster_cmd('osd', 'pool', 'create', 'foo', '1') | |
52 | ||
53 | osds = [0, 1, 2] | |
54 | for i in osds: | |
55 | manager.set_config(i, osd_min_pg_log_entries=10) | |
56 | manager.set_config(i, osd_max_pg_log_entries=10) | |
57 | manager.set_config(i, osd_pg_log_trim_min=5) | |
58 | ||
59 | # determine primary | |
60 | divergent = manager.get_pg_primary('foo', 0) | |
61 | log.info("primary and soon to be divergent is %d", divergent) | |
62 | non_divergent = list(osds) | |
63 | non_divergent.remove(divergent) | |
64 | ||
65 | log.info('writing initial objects') | |
66 | first_mon = teuthology.get_first_mon(ctx, config) | |
9f95a23c | 67 | (mon,) = ctx.cluster.only(first_mon).remotes.keys() |
7c673cae FG |
68 | # write 100 objects |
69 | for i in range(100): | |
70 | rados(ctx, mon, ['-p', 'foo', 'put', 'existing_%d' % i, dummyfile]) | |
71 | ||
72 | manager.wait_for_clean() | |
73 | ||
74 | # blackhole non_divergent | |
75 | log.info("blackholing osds %s", str(non_divergent)) | |
76 | for i in non_divergent: | |
77 | manager.set_config(i, objectstore_blackhole=1) | |
78 | ||
79 | DIVERGENT_WRITE = 5 | |
80 | DIVERGENT_REMOVE = 5 | |
81 | # Write some soon to be divergent | |
82 | log.info('writing divergent objects') | |
83 | for i in range(DIVERGENT_WRITE): | |
84 | rados(ctx, mon, ['-p', 'foo', 'put', 'existing_%d' % i, | |
85 | dummyfile2], wait=False) | |
86 | # Remove some soon to be divergent | |
87 | log.info('remove divergent objects') | |
88 | for i in range(DIVERGENT_REMOVE): | |
89 | rados(ctx, mon, ['-p', 'foo', 'rm', | |
90 | 'existing_%d' % (i + DIVERGENT_WRITE)], wait=False) | |
91 | time.sleep(10) | |
92 | mon.run( | |
93 | args=['killall', '-9', 'rados'], | |
94 | wait=True, | |
95 | check_status=False) | |
96 | ||
97 | # kill all the osds but leave divergent in | |
98 | log.info('killing all the osds') | |
99 | for i in osds: | |
100 | manager.kill_osd(i) | |
101 | for i in osds: | |
102 | manager.mark_down_osd(i) | |
103 | for i in non_divergent: | |
104 | manager.mark_out_osd(i) | |
105 | ||
106 | # bring up non-divergent | |
107 | log.info("bringing up non_divergent %s", str(non_divergent)) | |
108 | for i in non_divergent: | |
109 | manager.revive_osd(i) | |
110 | for i in non_divergent: | |
111 | manager.mark_in_osd(i) | |
112 | ||
113 | # write 1 non-divergent object (ensure that old divergent one is divergent) | |
114 | objname = "existing_%d" % (DIVERGENT_WRITE + DIVERGENT_REMOVE) | |
115 | log.info('writing non-divergent object ' + objname) | |
116 | rados(ctx, mon, ['-p', 'foo', 'put', objname, dummyfile2]) | |
117 | ||
118 | manager.wait_for_recovery() | |
119 | ||
120 | # ensure no recovery of up osds first | |
121 | log.info('delay recovery') | |
122 | for i in non_divergent: | |
123 | manager.wait_run_admin_socket( | |
124 | 'osd', i, ['set_recovery_delay', '100000']) | |
125 | ||
126 | # bring in our divergent friend | |
127 | log.info("revive divergent %d", divergent) | |
128 | manager.raw_cluster_cmd('osd', 'set', 'noup') | |
129 | manager.revive_osd(divergent) | |
130 | ||
131 | log.info('delay recovery divergent') | |
132 | manager.wait_run_admin_socket( | |
133 | 'osd', divergent, ['set_recovery_delay', '100000']) | |
134 | ||
135 | manager.raw_cluster_cmd('osd', 'unset', 'noup') | |
136 | while len(manager.get_osd_status()['up']) < 3: | |
137 | time.sleep(10) | |
138 | ||
139 | log.info('wait for peering') | |
140 | rados(ctx, mon, ['-p', 'foo', 'put', 'foo', dummyfile]) | |
141 | ||
142 | # At this point the divergent_priors should have been detected | |
143 | ||
144 | log.info("killing divergent %d", divergent) | |
145 | manager.kill_osd(divergent) | |
146 | ||
147 | # Export a pg | |
148 | (exp_remote,) = ctx.\ | |
9f95a23c | 149 | cluster.only('osd.{o}'.format(o=divergent)).remotes.keys() |
7c673cae FG |
150 | FSPATH = manager.get_filepath() |
151 | JPATH = os.path.join(FSPATH, "journal") | |
152 | prefix = ("sudo adjust-ulimits ceph-objectstore-tool " | |
153 | "--data-path {fpath} --journal-path {jpath} " | |
154 | "--log-file=" | |
155 | "/var/log/ceph/objectstore_tool.$$.log ". | |
156 | format(fpath=FSPATH, jpath=JPATH)) | |
157 | pid = os.getpid() | |
158 | expfile = os.path.join(testdir, "exp.{pid}.out".format(pid=pid)) | |
3efd9988 | 159 | cmd = ((prefix + "--op export-remove --pgid 2.0 --file {file}"). |
7c673cae | 160 | format(id=divergent, file=expfile)) |
9f95a23c TL |
161 | try: |
162 | exp_remote.sh(cmd, wait=True) | |
163 | except CommandFailedError as e: | |
164 | assert e.exitstatus == 0 | |
7c673cae FG |
165 | |
166 | cmd = ((prefix + "--op import --file {file}"). | |
167 | format(id=divergent, file=expfile)) | |
9f95a23c TL |
168 | try: |
169 | exp_remote.sh(cmd, wait=True) | |
170 | except CommandFailedError as e: | |
171 | assert e.exitstatus == 0 | |
7c673cae FG |
172 | |
173 | log.info("reviving divergent %d", divergent) | |
174 | manager.revive_osd(divergent) | |
175 | manager.wait_run_admin_socket('osd', divergent, ['dump_ops_in_flight']) | |
176 | time.sleep(20); | |
177 | ||
178 | log.info('allowing recovery') | |
179 | # Set osd_recovery_delay_start back to 0 and kick the queue | |
180 | for i in osds: | |
181 | manager.raw_cluster_cmd('tell', 'osd.%d' % i, 'debug', | |
182 | 'kick_recovery_wq', ' 0') | |
183 | ||
184 | log.info('reading divergent objects') | |
185 | for i in range(DIVERGENT_WRITE + DIVERGENT_REMOVE): | |
186 | exit_status = rados(ctx, mon, ['-p', 'foo', 'get', 'existing_%d' % i, | |
187 | '/tmp/existing']) | |
9f95a23c | 188 | assert exit_status == 0 |
7c673cae FG |
189 | |
190 | cmd = 'rm {file}'.format(file=expfile) | |
191 | exp_remote.run(args=cmd, wait=True) | |
192 | log.info("success") |