2013-10-12 08:28:27 +00:00
|
|
|
"""
|
|
|
|
Osd backfill test
|
|
|
|
"""
|
2012-02-01 00:25:53 +00:00
|
|
|
import logging
|
|
|
|
import time
|
2020-03-24 08:33:22 +00:00
|
|
|
from tasks import ceph_manager
|
2012-02-01 00:25:53 +00:00
|
|
|
from teuthology import misc as teuthology
|
|
|
|
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2013-01-23 20:37:39 +00:00
|
|
|
def rados_start(ctx, remote, cmd):
|
2013-10-12 08:28:27 +00:00
|
|
|
"""
|
|
|
|
Run a remote rados command (currently used to only write data)
|
|
|
|
"""
|
2012-02-01 00:25:53 +00:00
|
|
|
log.info("rados %s" % ' '.join(cmd))
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2012-02-01 00:25:53 +00:00
|
|
|
pre = [
|
2013-09-06 20:08:01 +00:00
|
|
|
'adjust-ulimits',
|
2013-02-06 19:16:52 +00:00
|
|
|
'ceph-coverage',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
2013-02-06 19:16:52 +00:00
|
|
|
'rados',
|
2012-02-01 00:25:53 +00:00
|
|
|
];
|
|
|
|
pre.extend(cmd)
|
|
|
|
proc = remote.run(
|
|
|
|
args=pre,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
return proc
|
|
|
|
|
|
|
|
def task(ctx, config):
|
|
|
|
"""
|
|
|
|
Test backfill
|
|
|
|
"""
|
|
|
|
if config is None:
|
|
|
|
config = {}
|
|
|
|
assert isinstance(config, dict), \
|
|
|
|
'thrashosds task only accepts a dict for configuration'
|
|
|
|
first_mon = teuthology.get_first_mon(ctx, config)
|
2019-10-11 15:57:47 +00:00
|
|
|
(mon,) = ctx.cluster.only(first_mon).remotes.keys()
|
2014-05-30 19:32:38 +00:00
|
|
|
|
2012-02-01 00:25:53 +00:00
|
|
|
num_osds = teuthology.num_instances_of_type(ctx.cluster, 'osd')
|
|
|
|
log.info('num_osds is %s' % num_osds)
|
2014-05-30 19:32:38 +00:00
|
|
|
assert num_osds == 3
|
2012-02-01 00:25:53 +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:
|
2016-06-02 22:24:56 +00:00
|
|
|
time.sleep(10)
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([0, 1, 2])
|
2012-02-18 05:53:25 +00:00
|
|
|
manager.wait_for_clean()
|
2012-02-01 00:25:53 +00:00
|
|
|
|
|
|
|
# write some data
|
2013-01-23 20:37:39 +00:00
|
|
|
p = rados_start(ctx, mon, ['-p', 'rbd', 'bench', '15', 'write', '-b', '4096',
|
2013-01-29 03:53:34 +00:00
|
|
|
'--no-cleanup'])
|
2014-05-30 19:32:38 +00:00
|
|
|
err = p.wait()
|
2012-02-01 00:25:53 +00:00
|
|
|
log.info('err is %d' % err)
|
|
|
|
|
|
|
|
# mark osd.0 out to trigger a rebalance/backfill
|
|
|
|
manager.mark_out_osd(0)
|
|
|
|
|
|
|
|
# also mark it down to it won't be included in pg_temps
|
|
|
|
manager.kill_osd(0)
|
|
|
|
manager.mark_down_osd(0)
|
|
|
|
|
2012-02-14 23:24:11 +00:00
|
|
|
# wait for everything to peer and be happy...
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([1, 2])
|
2012-02-18 05:53:25 +00:00
|
|
|
manager.wait_for_recovery()
|
2012-02-14 23:24:11 +00:00
|
|
|
|
2012-02-01 00:25:53 +00:00
|
|
|
# write some new data
|
2014-07-25 18:33:14 +00:00
|
|
|
p = rados_start(ctx, mon, ['-p', 'rbd', 'bench', '30', 'write', '-b', '4096',
|
2013-01-29 03:53:34 +00:00
|
|
|
'--no-cleanup'])
|
2012-02-01 00:25:53 +00:00
|
|
|
|
|
|
|
time.sleep(15)
|
|
|
|
|
|
|
|
# blackhole + restart osd.1
|
|
|
|
# this triggers a divergent backfill target
|
|
|
|
manager.blackhole_kill_osd(1)
|
|
|
|
time.sleep(2)
|
|
|
|
manager.revive_osd(1)
|
|
|
|
|
|
|
|
# wait for our writes to complete + succeed
|
2014-05-30 19:32:38 +00:00
|
|
|
err = p.wait()
|
2012-02-01 00:25:53 +00:00
|
|
|
log.info('err is %d' % err)
|
|
|
|
|
2016-12-20 02:55:54 +00:00
|
|
|
# wait for osd.1 and osd.2 to be up
|
|
|
|
manager.wait_till_osd_is_up(1)
|
|
|
|
manager.wait_till_osd_is_up(2)
|
|
|
|
|
2012-02-01 00:25:53 +00:00
|
|
|
# cluster must recover
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([1, 2])
|
2012-02-18 05:53:25 +00:00
|
|
|
manager.wait_for_recovery()
|
2012-02-01 00:25:53 +00:00
|
|
|
|
|
|
|
# re-add osd.0
|
|
|
|
manager.revive_osd(0)
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([1, 2])
|
2012-02-18 05:53:25 +00:00
|
|
|
manager.wait_for_clean()
|
2012-02-01 00:25:53 +00:00
|
|
|
|
|
|
|
|