2014-05-13 17:45:09 +00:00
|
|
|
"""
|
|
|
|
Test pool repairing after objects are damaged.
|
|
|
|
"""
|
2013-03-27 19:11:04 +00:00
|
|
|
import logging
|
2013-04-24 22:50:28 +00:00
|
|
|
import time
|
2013-03-27 19:11:04 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2014-11-21 14:52:25 +00:00
|
|
|
|
2016-03-25 01:19:12 +00:00
|
|
|
def choose_primary(manager, pool, num):
|
2014-05-13 17:45:09 +00:00
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
Return primary to test on.
|
2014-05-13 17:45:09 +00:00
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
log.info("Choosing primary")
|
2016-03-25 01:19:12 +00:00
|
|
|
return manager.get_pg_primary(pool, num)
|
2013-03-27 19:11:04 +00:00
|
|
|
|
2014-11-21 14:52:25 +00:00
|
|
|
|
2016-03-25 01:19:12 +00:00
|
|
|
def choose_replica(manager, pool, num):
|
2014-05-13 17:45:09 +00:00
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
Return replica to test on.
|
2014-05-13 17:45:09 +00:00
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
log.info("Choosing replica")
|
2016-03-25 01:19:12 +00:00
|
|
|
return manager.get_pg_replica(pool, num)
|
2013-03-27 19:11:04 +00:00
|
|
|
|
2014-11-21 14:52:25 +00:00
|
|
|
|
2016-03-25 01:19:12 +00:00
|
|
|
def trunc(manager, osd, pool, obj):
|
2014-05-13 17:45:09 +00:00
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
truncate an object
|
2014-05-13 17:45:09 +00:00
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
log.info("truncating object")
|
2016-03-25 01:19:12 +00:00
|
|
|
return manager.osd_admin_socket(
|
2014-11-21 15:13:26 +00:00
|
|
|
osd,
|
|
|
|
['truncobj', pool, obj, '1'])
|
2013-03-27 19:11:04 +00:00
|
|
|
|
2014-11-21 14:52:25 +00:00
|
|
|
|
2016-03-25 01:19:12 +00:00
|
|
|
def dataerr(manager, osd, pool, obj):
|
2014-05-13 17:45:09 +00:00
|
|
|
"""
|
2014-11-21 14:52:25 +00:00
|
|
|
cause an error in the data
|
2014-05-13 17:45:09 +00:00
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
log.info("injecting data err on object")
|
2016-03-25 01:19:12 +00:00
|
|
|
return manager.osd_admin_socket(
|
2014-11-21 15:13:26 +00:00
|
|
|
osd,
|
|
|
|
['injectdataerr', pool, obj])
|
|
|
|
|
2014-11-21 14:52:25 +00:00
|
|
|
|
2016-03-25 01:19:12 +00:00
|
|
|
def mdataerr(manager, osd, pool, obj):
|
2014-05-13 17:45:09 +00:00
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
cause an error in the mdata
|
2014-05-13 17:45:09 +00:00
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
log.info("injecting mdata err on object")
|
2016-03-25 01:19:12 +00:00
|
|
|
return manager.osd_admin_socket(
|
2014-11-21 15:13:26 +00:00
|
|
|
osd,
|
|
|
|
['injectmdataerr', pool, obj])
|
|
|
|
|
2014-11-21 14:52:25 +00:00
|
|
|
|
2016-03-25 01:19:12 +00:00
|
|
|
def omaperr(manager, osd, pool, obj):
|
2014-05-13 17:45:09 +00:00
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
Cause an omap error.
|
2014-05-13 17:45:09 +00:00
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
log.info("injecting omap err on object")
|
2016-03-25 01:19:12 +00:00
|
|
|
return manager.osd_admin_socket(osd, ['setomapval', pool, obj,
|
2014-11-21 14:52:25 +00:00
|
|
|
'badkey', 'badval'])
|
2014-05-13 17:45:09 +00:00
|
|
|
|
2014-11-21 15:43:29 +00:00
|
|
|
|
2016-03-25 01:19:12 +00:00
|
|
|
def repair_test_1(manager, corrupter, chooser, scrub_type):
|
2014-11-21 15:13:26 +00:00
|
|
|
"""
|
|
|
|
Creates an object in the pool, corrupts it,
|
2014-05-13 17:45:09 +00:00
|
|
|
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
|
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
pool = "repair_pool_1"
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.wait_for_clean()
|
|
|
|
with manager.pool(pool, 1):
|
2014-11-21 15:13:26 +00:00
|
|
|
|
2013-04-24 22:50:28 +00:00
|
|
|
log.info("starting repair test type 1")
|
2016-03-25 01:19:12 +00:00
|
|
|
victim_osd = chooser(manager, pool, 0)
|
2013-03-27 19:11:04 +00:00
|
|
|
|
|
|
|
# create object
|
|
|
|
log.info("doing put")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_put(pool, 'repair_test_obj', '/etc/hosts')
|
2013-03-27 19:11:04 +00:00
|
|
|
|
|
|
|
# corrupt object
|
|
|
|
log.info("corrupting object")
|
2016-03-25 01:19:12 +00:00
|
|
|
corrupter(manager, victim_osd, pool, 'repair_test_obj')
|
2013-03-27 19:11:04 +00:00
|
|
|
|
|
|
|
# verify inconsistent
|
|
|
|
log.info("scrubbing")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_pg_scrub(pool, 0, scrub_type)
|
2013-03-27 19:11:04 +00:00
|
|
|
|
2017-04-19 08:38:06 +00:00
|
|
|
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' in s)
|
2013-03-27 19:11:04 +00:00
|
|
|
|
|
|
|
# repair
|
|
|
|
log.info("repairing")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_pg_scrub(pool, 0, "repair")
|
2013-03-27 19:11:04 +00:00
|
|
|
|
|
|
|
log.info("re-scrubbing")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_pg_scrub(pool, 0, scrub_type)
|
2013-03-27 19:11:04 +00:00
|
|
|
|
|
|
|
# verify consistent
|
2017-04-19 08:38:06 +00:00
|
|
|
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' not in s)
|
2013-03-27 19:11:04 +00:00
|
|
|
log.info("done")
|
|
|
|
|
2014-11-21 14:52:25 +00:00
|
|
|
|
2016-03-25 01:19:12 +00:00
|
|
|
def repair_test_2(ctx, manager, config, chooser):
|
2014-05-13 17:45:09 +00:00
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
First creates a set of objects and
|
2014-05-13 17:45:09 +00:00
|
|
|
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
|
2014-11-21 14:52:25 +00:00
|
|
|
time after a deep-scrub.
|
2014-05-13 17:45:09 +00:00
|
|
|
|
|
|
|
:param chooser: primary or replica selection routine.
|
|
|
|
"""
|
2014-11-21 15:13:26 +00:00
|
|
|
pool = "repair_pool_2"
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.wait_for_clean()
|
|
|
|
with manager.pool(pool, 1):
|
2013-04-24 22:50:28 +00:00
|
|
|
log.info("starting repair test type 2")
|
2016-03-25 01:19:12 +00:00
|
|
|
victim_osd = chooser(manager, pool, 0)
|
2013-04-24 22:50:28 +00:00
|
|
|
|
|
|
|
# create object
|
|
|
|
log.info("doing put and setomapval")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_put(pool, 'file1', '/etc/hosts')
|
2021-03-10 22:30:32 +00:00
|
|
|
manager.do_rados(['setomapval', 'file1', 'key', 'val'], pool=pool)
|
2016-03-25 01:19:12 +00:00
|
|
|
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')
|
2021-03-10 22:30:32 +00:00
|
|
|
manager.do_rados(['setomapval', 'file5', 'key', 'val'], pool=pool)
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_put(pool, 'file6', '/etc/hosts')
|
2013-04-24 22:50:28 +00:00
|
|
|
|
|
|
|
# corrupt object
|
|
|
|
log.info("corrupting object")
|
2016-03-25 01:19:12 +00:00
|
|
|
omaperr(manager, victim_osd, pool, 'file1')
|
2013-04-24 22:50:28 +00:00
|
|
|
|
|
|
|
# verify inconsistent
|
|
|
|
log.info("scrubbing")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_pg_scrub(pool, 0, 'deep-scrub')
|
2013-04-24 22:50:28 +00:00
|
|
|
|
2017-04-19 08:38:06 +00:00
|
|
|
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' in s)
|
2013-04-24 22:50:28 +00:00
|
|
|
|
|
|
|
# Regression test for bug #4778, should still
|
|
|
|
# be inconsistent after scrub
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_pg_scrub(pool, 0, 'scrub')
|
2013-04-24 22:50:28 +00:00
|
|
|
|
2017-04-19 08:38:06 +00:00
|
|
|
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' in s)
|
2013-04-24 22:50:28 +00:00
|
|
|
|
|
|
|
# Additional corruptions including 2 types for file1
|
|
|
|
log.info("corrupting more objects")
|
2016-03-25 01:19:12 +00:00
|
|
|
dataerr(manager, victim_osd, pool, 'file1')
|
|
|
|
mdataerr(manager, victim_osd, pool, 'file2')
|
|
|
|
trunc(manager, victim_osd, pool, 'file3')
|
|
|
|
omaperr(manager, victim_osd, pool, 'file6')
|
2013-04-24 22:50:28 +00:00
|
|
|
|
|
|
|
# see still inconsistent
|
|
|
|
log.info("scrubbing")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_pg_scrub(pool, 0, 'deep-scrub')
|
2013-04-24 22:50:28 +00:00
|
|
|
|
2017-04-19 08:38:06 +00:00
|
|
|
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' in s)
|
2013-04-24 22:50:28 +00:00
|
|
|
|
|
|
|
# repair
|
|
|
|
log.info("repairing")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_pg_scrub(pool, 0, "repair")
|
2013-04-24 22:50:28 +00:00
|
|
|
|
|
|
|
# Let repair clear inconsistent flag
|
|
|
|
time.sleep(10)
|
|
|
|
|
|
|
|
# verify consistent
|
2017-04-19 08:38:06 +00:00
|
|
|
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' not in s)
|
2013-04-24 22:50:28 +00:00
|
|
|
|
|
|
|
# In the future repair might determine state of
|
|
|
|
# inconsistency itself, verify with a deep-scrub
|
|
|
|
log.info("scrubbing")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_pg_scrub(pool, 0, 'deep-scrub')
|
2013-04-24 22:50:28 +00:00
|
|
|
|
|
|
|
# verify consistent
|
2017-04-19 08:38:06 +00:00
|
|
|
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' not in s)
|
2013-04-24 22:50:28 +00:00
|
|
|
|
|
|
|
log.info("done")
|
2014-11-21 15:13:26 +00:00
|
|
|
|
2013-04-24 22:50:28 +00:00
|
|
|
|
2016-03-25 01:19:12 +00:00
|
|
|
def hinfoerr(manager, victim, pool, obj):
|
2014-11-21 15:43:29 +00:00
|
|
|
"""
|
|
|
|
cause an error in the hinfo_key
|
|
|
|
"""
|
|
|
|
log.info("remove the hinfo_key")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.objectstore_tool(pool,
|
|
|
|
options='',
|
|
|
|
args='rm-attr hinfo_key',
|
|
|
|
object_name=obj,
|
|
|
|
osd=victim)
|
2014-11-21 15:43:29 +00:00
|
|
|
|
|
|
|
|
2016-03-25 01:19:12 +00:00
|
|
|
def repair_test_erasure_code(manager, corrupter, victim, scrub_type):
|
2014-11-21 15:43:29 +00:00
|
|
|
"""
|
|
|
|
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"
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.wait_for_clean()
|
|
|
|
with manager.pool(pool_name=pool, pg_num=1,
|
2014-11-21 15:43:29 +00:00
|
|
|
erasure_code_profile_name='default'):
|
|
|
|
|
|
|
|
log.info("starting repair test for erasure code")
|
|
|
|
|
|
|
|
# create object
|
|
|
|
log.info("doing put")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_put(pool, 'repair_test_obj', '/etc/hosts')
|
2014-11-21 15:43:29 +00:00
|
|
|
|
|
|
|
# corrupt object
|
|
|
|
log.info("corrupting object")
|
2016-03-25 01:19:12 +00:00
|
|
|
corrupter(manager, victim, pool, 'repair_test_obj')
|
2014-11-21 15:43:29 +00:00
|
|
|
|
|
|
|
# verify inconsistent
|
|
|
|
log.info("scrubbing")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_pg_scrub(pool, 0, scrub_type)
|
2014-11-21 15:43:29 +00:00
|
|
|
|
2017-04-19 08:38:06 +00:00
|
|
|
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' in s)
|
2014-11-21 15:43:29 +00:00
|
|
|
|
|
|
|
# repair
|
|
|
|
log.info("repairing")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_pg_scrub(pool, 0, "repair")
|
2014-11-21 15:43:29 +00:00
|
|
|
|
|
|
|
log.info("re-scrubbing")
|
2016-03-25 01:19:12 +00:00
|
|
|
manager.do_pg_scrub(pool, 0, scrub_type)
|
2014-11-21 15:43:29 +00:00
|
|
|
|
|
|
|
# verify consistent
|
2017-04-19 08:38:06 +00:00
|
|
|
manager.with_pg_state(pool, 0, lambda s: 'inconsistent' not in s)
|
2014-11-21 15:43:29 +00:00
|
|
|
log.info("done")
|
|
|
|
|
|
|
|
|
2013-03-27 19:11:04 +00:00
|
|
|
def task(ctx, config):
|
|
|
|
"""
|
|
|
|
Test [deep] repair in several situations:
|
|
|
|
Repair [Truncate, Data EIO, MData EIO] on [Primary|Replica]
|
2013-04-24 22:50:28 +00:00
|
|
|
|
|
|
|
The config should be as follows:
|
|
|
|
|
2020-06-17 19:33:57 +00:00
|
|
|
Must include the log-ignorelist below
|
2013-04-24 22:50:28 +00:00
|
|
|
Must enable filestore_debug_inject_read_err config
|
|
|
|
|
|
|
|
example:
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- chef:
|
|
|
|
- install:
|
|
|
|
- ceph:
|
2020-06-17 19:33:57 +00:00
|
|
|
log-ignorelist:
|
2015-11-25 15:29:27 +00:00
|
|
|
- 'candidate had a stat error'
|
2014-11-21 14:52:25 +00:00
|
|
|
- 'candidate had a read error'
|
|
|
|
- 'deep-scrub 0 missing, 1 inconsistent objects'
|
|
|
|
- 'deep-scrub 0 missing, 4 inconsistent objects'
|
2016-10-20 00:10:07 +00:00
|
|
|
- 'deep-scrub [0-9]+ errors'
|
|
|
|
- '!= omap_digest'
|
|
|
|
- '!= data_digest'
|
2014-11-21 14:52:25 +00:00
|
|
|
- 'repair 0 missing, 1 inconsistent objects'
|
|
|
|
- 'repair 0 missing, 4 inconsistent objects'
|
2016-10-20 00:10:07 +00:00
|
|
|
- 'repair [0-9]+ errors, [0-9]+ fixed'
|
|
|
|
- 'scrub 0 missing, 1 inconsistent objects'
|
|
|
|
- 'scrub [0-9]+ errors'
|
|
|
|
- 'size 1 != size'
|
|
|
|
- 'attr name mismatch'
|
2017-06-15 01:40:09 +00:00
|
|
|
- 'Regular scrub request, deep-scrub details will be lost'
|
2018-08-06 17:37:04 +00:00
|
|
|
- 'candidate size [0-9]+ info size [0-9]+ mismatch'
|
2013-04-24 22:50:28 +00:00
|
|
|
conf:
|
|
|
|
osd:
|
|
|
|
filestore debug inject read err: true
|
|
|
|
- repair_test:
|
|
|
|
|
2013-03-27 19:11:04 +00:00
|
|
|
"""
|
|
|
|
if config is None:
|
|
|
|
config = {}
|
|
|
|
assert isinstance(config, dict), \
|
|
|
|
'repair_test task only accepts a dict for config'
|
|
|
|
|
2016-03-25 01:19:12 +00:00
|
|
|
manager = ctx.managers['ceph']
|
2017-07-22 19:18:26 +00:00
|
|
|
manager.wait_for_all_osds_up()
|
2016-03-25 01:19:12 +00:00
|
|
|
|
|
|
|
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")
|
2017-05-25 22:05:42 +00:00
|
|
|
|
|
|
|
manager.raw_cluster_cmd('osd', 'unset', 'noscrub')
|
|
|
|
manager.raw_cluster_cmd('osd', 'unset', 'nodeep-scrub')
|