1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
"""
Test pool repairing after objects are damaged.
"""
import logging
import time
log = logging.getLogger(__name__)
def choose_primary(manager, pool, num):
"""
Return primary to test on.
"""
log.info("Choosing primary")
return manager.get_pg_primary(pool, num)
def choose_replica(manager, pool, num):
"""
Return replica to test on.
"""
log.info("Choosing replica")
return manager.get_pg_replica(pool, num)
def trunc(manager, osd, pool, obj):
"""
truncate an object
"""
log.info("truncating object")
return manager.osd_admin_socket(
osd,
['truncobj', pool, obj, '1'])
def dataerr(manager, osd, pool, obj):
"""
cause an error in the data
"""
log.info("injecting data err on object")
return manager.osd_admin_socket(
osd,
['injectdataerr', pool, obj])
def mdataerr(manager, osd, pool, obj):
"""
cause an error in the mdata
"""
log.info("injecting mdata err on object")
return manager.osd_admin_socket(
osd,
['injectmdataerr', pool, obj])
def omaperr(manager, osd, pool, obj):
"""
Cause an omap error.
"""
log.info("injecting omap err on object")
return manager.osd_admin_socket(osd, ['setomapval', pool, obj,
'badkey', 'badval'])
def repair_test_1(manager, corrupter, chooser, scrub_type):
"""
Creates an object in the pool, corrupts it,
scrubs it, and verifies that the pool is inconsistent. It then repairs
the pool, rescrubs it, and verifies that the pool is consistent
:param corrupter: error generating function (truncate, data-error, or
meta-data error, for example).
:param chooser: osd type chooser (primary or replica)
:param scrub_type: regular scrub or deep-scrub
"""
pool = "repair_pool_1"
manager.wait_for_clean()
with manager.pool(pool, 1):
log.info("starting repair test type 1")
victim_osd = chooser(manager, pool, 0)
# create object
log.info("doing put")
manager.do_put(pool, 'repair_test_obj', '/etc/hosts')
# corrupt object
log.info("corrupting object")
corrupter(manager, victim_osd, pool, 'repair_test_obj')
# verify inconsistent
log.info("scrubbing")
manager.do_pg_scrub(pool, 0, scrub_type)
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' in s)
# repair
log.info("repairing")
manager.do_pg_scrub(pool, 0, "repair")
log.info("re-scrubbing")
manager.do_pg_scrub(pool, 0, scrub_type)
# verify consistent
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' not in s)
log.info("done")
def repair_test_2(ctx, manager, config, chooser):
"""
First creates a set of objects and
sets the omap value. It then corrupts an object, does both a scrub
and a deep-scrub, and then corrupts more objects. After that, it
repairs the pool and makes sure that the pool is consistent some
time after a deep-scrub.
:param chooser: primary or replica selection routine.
"""
pool = "repair_pool_2"
manager.wait_for_clean()
with manager.pool(pool, 1):
log.info("starting repair test type 2")
victim_osd = chooser(manager, pool, 0)
# create object
log.info("doing put and setomapval")
manager.do_put(pool, 'file1', '/etc/hosts')
manager.do_rados(['setomapval', 'file1', 'key', 'val'], pool=pool)
manager.do_put(pool, 'file2', '/etc/hosts')
manager.do_put(pool, 'file3', '/etc/hosts')
manager.do_put(pool, 'file4', '/etc/hosts')
manager.do_put(pool, 'file5', '/etc/hosts')
manager.do_rados(['setomapval', 'file5', 'key', 'val'], pool=pool)
manager.do_put(pool, 'file6', '/etc/hosts')
# corrupt object
log.info("corrupting object")
omaperr(manager, victim_osd, pool, 'file1')
# verify inconsistent
log.info("scrubbing")
manager.do_pg_scrub(pool, 0, 'deep-scrub')
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' in s)
# Regression test for bug #4778, should still
# be inconsistent after scrub
manager.do_pg_scrub(pool, 0, 'scrub')
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' in s)
# Additional corruptions including 2 types for file1
log.info("corrupting more objects")
dataerr(manager, victim_osd, pool, 'file1')
mdataerr(manager, victim_osd, pool, 'file2')
trunc(manager, victim_osd, pool, 'file3')
omaperr(manager, victim_osd, pool, 'file6')
# see still inconsistent
log.info("scrubbing")
manager.do_pg_scrub(pool, 0, 'deep-scrub')
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' in s)
# repair
log.info("repairing")
manager.do_pg_scrub(pool, 0, "repair")
# Let repair clear inconsistent flag
time.sleep(10)
# verify consistent
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' not in s)
# In the future repair might determine state of
# inconsistency itself, verify with a deep-scrub
log.info("scrubbing")
manager.do_pg_scrub(pool, 0, 'deep-scrub')
# verify consistent
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' not in s)
log.info("done")
def hinfoerr(manager, victim, pool, obj):
"""
cause an error in the hinfo_key
"""
log.info("remove the hinfo_key")
manager.objectstore_tool(pool,
options='',
args='rm-attr hinfo_key',
object_name=obj,
osd=victim)
def repair_test_erasure_code(manager, corrupter, victim, scrub_type):
"""
Creates an object in the pool, corrupts it,
scrubs it, and verifies that the pool is inconsistent. It then repairs
the pool, rescrubs it, and verifies that the pool is consistent
:param corrupter: error generating function.
:param chooser: osd type chooser (primary or replica)
:param scrub_type: regular scrub or deep-scrub
"""
pool = "repair_pool_3"
manager.wait_for_clean()
with manager.pool(pool_name=pool, pg_num=1,
erasure_code_profile_name='default'):
log.info("starting repair test for erasure code")
# create object
log.info("doing put")
manager.do_put(pool, 'repair_test_obj', '/etc/hosts')
# corrupt object
log.info("corrupting object")
corrupter(manager, victim, pool, 'repair_test_obj')
# verify inconsistent
log.info("scrubbing")
manager.do_pg_scrub(pool, 0, scrub_type)
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' in s)
# repair
log.info("repairing")
manager.do_pg_scrub(pool, 0, "repair")
log.info("re-scrubbing")
manager.do_pg_scrub(pool, 0, scrub_type)
# verify consistent
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' not in s)
log.info("done")
def task(ctx, config):
"""
Test [deep] repair in several situations:
Repair [Truncate, Data EIO, MData EIO] on [Primary|Replica]
The config should be as follows:
Must include the log-ignorelist below
Must enable filestore_debug_inject_read_err config
example:
tasks:
- chef:
- install:
- ceph:
log-ignorelist:
- 'candidate had a stat error'
- 'candidate had a read error'
- 'deep-scrub 0 missing, 1 inconsistent objects'
- 'deep-scrub 0 missing, 4 inconsistent objects'
- 'deep-scrub [0-9]+ errors'
- '!= omap_digest'
- '!= data_digest'
- 'repair 0 missing, 1 inconsistent objects'
- 'repair 0 missing, 4 inconsistent objects'
- 'repair [0-9]+ errors, [0-9]+ fixed'
- 'scrub 0 missing, 1 inconsistent objects'
- 'scrub [0-9]+ errors'
- 'size 1 != size'
- 'attr name mismatch'
- 'Regular scrub request, deep-scrub details will be lost'
- 'candidate size [0-9]+ info size [0-9]+ mismatch'
conf:
osd:
filestore debug inject read err: true
- repair_test:
"""
if config is None:
config = {}
assert isinstance(config, dict), \
'repair_test task only accepts a dict for config'
manager = ctx.managers['ceph']
manager.wait_for_all_osds_up()
manager.raw_cluster_cmd('osd', 'set', 'noscrub')
manager.raw_cluster_cmd('osd', 'set', 'nodeep-scrub')
repair_test_1(manager, mdataerr, choose_primary, "scrub")
repair_test_1(manager, mdataerr, choose_replica, "scrub")
repair_test_1(manager, dataerr, choose_primary, "deep-scrub")
repair_test_1(manager, dataerr, choose_replica, "deep-scrub")
repair_test_1(manager, trunc, choose_primary, "scrub")
repair_test_1(manager, trunc, choose_replica, "scrub")
repair_test_2(ctx, manager, config, choose_primary)
repair_test_2(ctx, manager, config, choose_replica)
repair_test_erasure_code(manager, hinfoerr, 'primary', "deep-scrub")
manager.raw_cluster_cmd('osd', 'unset', 'noscrub')
manager.raw_cluster_cmd('osd', 'unset', 'nodeep-scrub')
|