2013-10-12 08:28:27 +00:00
|
|
|
"""
|
|
|
|
Lost_unfound
|
|
|
|
"""
|
2011-10-17 22:32:22 +00:00
|
|
|
import logging
|
2015-03-03 22:38:10 +00:00
|
|
|
import time
|
2020-03-24 08:33:22 +00:00
|
|
|
from tasks import ceph_manager
|
|
|
|
from tasks.util.rados import rados
|
2011-10-17 22:32:22 +00:00
|
|
|
from teuthology import misc as teuthology
|
2015-12-22 18:06:22 +00:00
|
|
|
from teuthology.orchestra import run
|
2011-10-17 22:32:22 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
def task(ctx, config):
|
|
|
|
"""
|
|
|
|
Test handling of lost objects.
|
2013-10-12 08:28:27 +00:00
|
|
|
|
2020-09-13 17:09:53 +00:00
|
|
|
A pretty rigid cluster is brought up and tested by this task
|
2011-10-17 22:32:22 +00:00
|
|
|
"""
|
2014-08-01 16:36:10 +00:00
|
|
|
POOL = 'unfound_pool'
|
2011-10-17 22:32:22 +00:00
|
|
|
if config is None:
|
|
|
|
config = {}
|
|
|
|
assert isinstance(config, dict), \
|
2012-01-11 00:21:00 +00:00
|
|
|
'lost_unfound task only accepts a dict for configuration'
|
2011-10-17 22:32:22 +00:00
|
|
|
first_mon = teuthology.get_first_mon(ctx, config)
|
2019-10-11 15:57:47 +00:00
|
|
|
(mon,) = ctx.cluster.only(first_mon).remotes.keys()
|
2011-10-17 22:32:22 +00:00
|
|
|
|
|
|
|
manager = ceph_manager.CephManager(
|
|
|
|
mon,
|
|
|
|
ctx=ctx,
|
|
|
|
logger=log.getChild('ceph_manager'),
|
|
|
|
)
|
|
|
|
|
2012-04-19 19:43:54 +00:00
|
|
|
while len(manager.get_osd_status()['up']) < 3:
|
2015-03-03 22:38:10 +00:00
|
|
|
time.sleep(10)
|
2016-06-17 15:16:56 +00:00
|
|
|
|
2012-02-18 05:53:25 +00:00
|
|
|
manager.wait_for_clean()
|
2011-10-17 22:32:22 +00:00
|
|
|
|
2014-08-01 16:36:10 +00:00
|
|
|
manager.create_pool(POOL)
|
|
|
|
|
2011-10-17 22:32:22 +00:00
|
|
|
# something that is always there
|
|
|
|
dummyfile = '/etc/fstab'
|
|
|
|
|
|
|
|
# take an osd out until the very end
|
|
|
|
manager.kill_osd(2)
|
|
|
|
manager.mark_down_osd(2)
|
|
|
|
manager.mark_out_osd(2)
|
|
|
|
|
|
|
|
# kludge to make sure they get a map
|
2014-08-01 16:36:10 +00:00
|
|
|
rados(ctx, mon, ['-p', POOL, 'put', 'dummy', dummyfile])
|
2011-10-17 22:32:22 +00:00
|
|
|
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([0, 1])
|
2012-02-18 05:53:25 +00:00
|
|
|
manager.wait_for_recovery()
|
2011-10-17 22:32:22 +00:00
|
|
|
|
|
|
|
# create old objects
|
|
|
|
for f in range(1, 10):
|
2014-08-01 16:36:10 +00:00
|
|
|
rados(ctx, mon, ['-p', POOL, 'put', 'existing_%d' % f, dummyfile])
|
|
|
|
rados(ctx, mon, ['-p', POOL, 'put', 'existed_%d' % f, dummyfile])
|
|
|
|
rados(ctx, mon, ['-p', POOL, 'rm', 'existed_%d' % f])
|
2011-10-17 22:32:22 +00:00
|
|
|
|
2012-01-12 23:08:11 +00:00
|
|
|
# delay recovery, and make the pg log very long (to prevent backfill)
|
2011-10-17 22:32:22 +00:00
|
|
|
manager.raw_cluster_cmd(
|
|
|
|
'tell', 'osd.1',
|
2012-01-12 23:08:11 +00:00
|
|
|
'injectargs',
|
|
|
|
'--osd-recovery-delay-start 1000 --osd-min-pg-log-entries 100000000'
|
2011-10-17 22:32:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
manager.kill_osd(0)
|
|
|
|
manager.mark_down_osd(0)
|
|
|
|
|
|
|
|
for f in range(1, 10):
|
2014-08-01 16:36:10 +00:00
|
|
|
rados(ctx, mon, ['-p', POOL, 'put', 'new_%d' % f, dummyfile])
|
|
|
|
rados(ctx, mon, ['-p', POOL, 'put', 'existed_%d' % f, dummyfile])
|
|
|
|
rados(ctx, mon, ['-p', POOL, 'put', 'existing_%d' % f, dummyfile])
|
2011-10-17 22:32:22 +00:00
|
|
|
|
|
|
|
# bring osd.0 back up, let it peer, but don't replicate the new
|
|
|
|
# objects...
|
|
|
|
log.info('osd.0 command_args is %s' % 'foo')
|
|
|
|
log.info(ctx.daemons.get_daemon('osd', 0).command_args)
|
|
|
|
ctx.daemons.get_daemon('osd', 0).command_kwargs['args'].extend([
|
|
|
|
'--osd-recovery-delay-start', '1000'
|
|
|
|
])
|
|
|
|
manager.revive_osd(0)
|
2012-02-20 03:40:45 +00:00
|
|
|
manager.mark_in_osd(0)
|
2011-10-17 22:32:22 +00:00
|
|
|
manager.wait_till_osd_is_up(0)
|
|
|
|
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([1, 0])
|
2011-10-17 22:32:22 +00:00
|
|
|
manager.wait_till_active()
|
|
|
|
|
|
|
|
# take out osd.1 and the only copy of those objects.
|
|
|
|
manager.kill_osd(1)
|
|
|
|
manager.mark_down_osd(1)
|
|
|
|
manager.mark_out_osd(1)
|
|
|
|
manager.raw_cluster_cmd('osd', 'lost', '1', '--yes-i-really-mean-it')
|
|
|
|
|
|
|
|
# bring up osd.2 so that things would otherwise, in theory, recovery fully
|
|
|
|
manager.revive_osd(2)
|
2012-02-20 03:40:45 +00:00
|
|
|
manager.mark_in_osd(2)
|
2011-10-17 22:32:22 +00:00
|
|
|
manager.wait_till_osd_is_up(2)
|
|
|
|
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([0, 2])
|
2011-10-17 22:32:22 +00:00
|
|
|
manager.wait_till_active()
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([0, 2])
|
2011-10-17 22:32:22 +00:00
|
|
|
|
|
|
|
# verify that there are unfound objects
|
|
|
|
unfound = manager.get_num_unfound_objects()
|
|
|
|
log.info("there are %d unfound objects" % unfound)
|
|
|
|
assert unfound
|
|
|
|
|
2015-12-22 18:06:22 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
|
|
|
procs = []
|
|
|
|
if config.get('parallel_bench', True):
|
|
|
|
procs.append(mon.run(
|
|
|
|
args=[
|
|
|
|
"/bin/sh", "-c",
|
|
|
|
" ".join(['adjust-ulimits',
|
|
|
|
'ceph-coverage',
|
|
|
|
'{tdir}/archive/coverage',
|
|
|
|
'rados',
|
|
|
|
'--no-log-to-stderr',
|
|
|
|
'--name', 'client.admin',
|
|
|
|
'-b', str(4<<10),
|
|
|
|
'-p' , POOL,
|
|
|
|
'-t', '20',
|
|
|
|
'bench', '240', 'write',
|
|
|
|
]).format(tdir=testdir),
|
|
|
|
],
|
|
|
|
logger=log.getChild('radosbench.{id}'.format(id='client.admin')),
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False
|
|
|
|
))
|
|
|
|
time.sleep(10)
|
|
|
|
|
2011-10-17 22:32:22 +00:00
|
|
|
# mark stuff lost
|
|
|
|
pgs = manager.get_pg_stats()
|
|
|
|
for pg in pgs:
|
|
|
|
if pg['stat_sum']['num_objects_unfound'] > 0:
|
|
|
|
primary = 'osd.%d' % pg['acting'][0]
|
2012-02-24 19:11:59 +00:00
|
|
|
|
|
|
|
# verify that i can list them direct from the osd
|
2012-03-02 18:55:19 +00:00
|
|
|
log.info('listing missing/lost in %s state %s', pg['pgid'],
|
|
|
|
pg['state']);
|
2018-08-23 06:29:01 +00:00
|
|
|
m = manager.list_pg_unfound(pg['pgid'])
|
2012-02-24 19:11:59 +00:00
|
|
|
#log.info('%s' % m)
|
|
|
|
assert m['num_unfound'] == pg['stat_sum']['num_objects_unfound']
|
2020-07-29 00:38:44 +00:00
|
|
|
assert m['available_might_have_unfound'] == True
|
|
|
|
assert m['might_have_unfound'][0]['osd'] == "1"
|
|
|
|
assert m['might_have_unfound'][0]['status'] == "osd is down"
|
2012-02-24 19:11:59 +00:00
|
|
|
num_unfound=0
|
|
|
|
for o in m['objects']:
|
|
|
|
if len(o['locations']) == 0:
|
|
|
|
num_unfound += 1
|
|
|
|
assert m['num_unfound'] == num_unfound
|
|
|
|
|
2011-10-17 22:32:22 +00:00
|
|
|
log.info("reverting unfound in %s on %s", pg['pgid'], primary)
|
2012-02-24 04:07:24 +00:00
|
|
|
manager.raw_cluster_cmd('pg', pg['pgid'],
|
|
|
|
'mark_unfound_lost', 'revert')
|
2011-10-17 22:32:22 +00:00
|
|
|
else:
|
|
|
|
log.info("no unfound in %s", pg['pgid'])
|
|
|
|
|
|
|
|
manager.raw_cluster_cmd('tell', 'osd.0', 'debug', 'kick_recovery_wq', '5')
|
|
|
|
manager.raw_cluster_cmd('tell', 'osd.2', 'debug', 'kick_recovery_wq', '5')
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([0, 2])
|
2012-02-18 05:53:25 +00:00
|
|
|
manager.wait_for_recovery()
|
2011-10-17 22:32:22 +00:00
|
|
|
|
|
|
|
# verify result
|
|
|
|
for f in range(1, 10):
|
2014-08-01 16:36:10 +00:00
|
|
|
err = rados(ctx, mon, ['-p', POOL, 'get', 'new_%d' % f, '-'])
|
2011-10-17 22:32:22 +00:00
|
|
|
assert err
|
2014-08-01 16:36:10 +00:00
|
|
|
err = rados(ctx, mon, ['-p', POOL, 'get', 'existed_%d' % f, '-'])
|
2011-10-17 22:32:22 +00:00
|
|
|
assert err
|
2014-08-01 16:36:10 +00:00
|
|
|
err = rados(ctx, mon, ['-p', POOL, 'get', 'existing_%d' % f, '-'])
|
2011-10-17 22:32:22 +00:00
|
|
|
assert not err
|
|
|
|
|
|
|
|
# see if osd.1 can cope
|
2012-02-20 03:40:45 +00:00
|
|
|
manager.mark_in_osd(1)
|
2017-08-25 09:07:37 +00:00
|
|
|
manager.revive_osd(1)
|
2011-10-17 22:32:22 +00:00
|
|
|
manager.wait_till_osd_is_up(1)
|
2012-02-18 05:53:25 +00:00
|
|
|
manager.wait_for_clean()
|
2015-12-22 18:06:22 +00:00
|
|
|
run.wait(procs)
|
2021-03-16 19:48:40 +00:00
|
|
|
manager.wait_for_clean()
|