2013-10-12 08:28:27 +00:00
|
|
|
"""
|
|
|
|
Special case divergence test
|
|
|
|
"""
|
2012-11-09 00:22:40 +00:00
|
|
|
import logging
|
2013-07-22 21:21:51 +00:00
|
|
|
import time
|
|
|
|
|
2012-11-09 00:22:40 +00:00
|
|
|
from teuthology import misc as teuthology
|
2014-08-07 14:24:59 +00:00
|
|
|
from util.rados import rados
|
2012-11-09 00:22:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2015-05-05 04:13:08 +00:00
|
|
|
|
2012-11-09 00:22:40 +00:00
|
|
|
def task(ctx, config):
|
|
|
|
"""
|
|
|
|
Test handling of divergent entries with prior_version
|
|
|
|
prior to log_tail
|
|
|
|
|
2015-05-05 04:13:08 +00:00
|
|
|
overrides:
|
|
|
|
ceph:
|
|
|
|
conf:
|
|
|
|
osd:
|
|
|
|
debug osd: 5
|
2012-11-09 00:22:40 +00:00
|
|
|
|
2015-05-05 04:13:08 +00:00
|
|
|
Requires 3 osds on a single test node.
|
2012-11-09 00:22:40 +00:00
|
|
|
"""
|
|
|
|
if config is None:
|
|
|
|
config = {}
|
|
|
|
assert isinstance(config, dict), \
|
|
|
|
'divergent_priors task only accepts a dict for configuration'
|
|
|
|
|
2014-08-15 13:56:52 +00:00
|
|
|
while len(ctx.manager.get_osd_status()['up']) < 3:
|
2012-11-09 00:22:40 +00:00
|
|
|
time.sleep(10)
|
2014-08-15 13:56:52 +00:00
|
|
|
ctx.manager.raw_cluster_cmd('tell', 'osd.0', 'flush_pg_stats')
|
|
|
|
ctx.manager.raw_cluster_cmd('tell', 'osd.1', 'flush_pg_stats')
|
|
|
|
ctx.manager.raw_cluster_cmd('tell', 'osd.2', 'flush_pg_stats')
|
|
|
|
ctx.manager.raw_cluster_cmd('osd', 'set', 'noout')
|
|
|
|
ctx.manager.raw_cluster_cmd('osd', 'set', 'noin')
|
|
|
|
ctx.manager.raw_cluster_cmd('osd', 'set', 'nodown')
|
|
|
|
ctx.manager.wait_for_clean()
|
2012-11-09 00:22:40 +00:00
|
|
|
|
|
|
|
# something that is always there
|
|
|
|
dummyfile = '/etc/fstab'
|
|
|
|
dummyfile2 = '/etc/resolv.conf'
|
|
|
|
|
|
|
|
# create 1 pg pool
|
|
|
|
log.info('creating foo')
|
2014-08-15 13:56:52 +00:00
|
|
|
ctx.manager.raw_cluster_cmd('osd', 'pool', 'create', 'foo', '1')
|
2012-11-09 00:22:40 +00:00
|
|
|
|
|
|
|
osds = [0, 1, 2]
|
|
|
|
for i in osds:
|
2015-05-05 04:13:08 +00:00
|
|
|
ctx.manager.set_config(i, osd_min_pg_log_entries=10)
|
|
|
|
ctx.manager.set_config(i, osd_max_pg_log_entries=10)
|
|
|
|
ctx.manager.set_config(i, osd_pg_log_trim_min=5)
|
2012-11-09 00:22:40 +00:00
|
|
|
|
|
|
|
# determine primary
|
2014-08-15 13:56:52 +00:00
|
|
|
divergent = ctx.manager.get_pg_primary('foo', 0)
|
2012-11-09 00:22:40 +00:00
|
|
|
log.info("primary and soon to be divergent is %d", divergent)
|
2015-05-05 04:13:08 +00:00
|
|
|
non_divergent = list(osds)
|
2012-11-09 00:22:40 +00:00
|
|
|
non_divergent.remove(divergent)
|
|
|
|
|
|
|
|
log.info('writing initial objects')
|
2015-02-26 16:24:41 +00:00
|
|
|
first_mon = teuthology.get_first_mon(ctx, config)
|
|
|
|
(mon,) = ctx.cluster.only(first_mon).remotes.iterkeys()
|
2015-05-05 04:13:08 +00:00
|
|
|
# write 100 objects
|
|
|
|
for i in range(100):
|
2013-07-22 21:21:51 +00:00
|
|
|
rados(ctx, mon, ['-p', 'foo', 'put', 'existing_%d' % i, dummyfile])
|
2012-11-09 00:22:40 +00:00
|
|
|
|
2014-08-15 13:56:52 +00:00
|
|
|
ctx.manager.wait_for_clean()
|
2012-11-09 00:22:40 +00:00
|
|
|
|
|
|
|
# blackhole non_divergent
|
|
|
|
log.info("blackholing osds %s", str(non_divergent))
|
|
|
|
for i in non_divergent:
|
2015-05-05 04:13:08 +00:00
|
|
|
ctx.manager.set_config(i, filestore_blackhole=1)
|
|
|
|
|
|
|
|
DIVERGENT_WRITE = 5
|
|
|
|
DIVERGENT_REMOVE = 5
|
|
|
|
# Write some soon to be divergent
|
|
|
|
log.info('writing divergent objects')
|
|
|
|
for i in range(DIVERGENT_WRITE):
|
|
|
|
rados(ctx, mon, ['-p', 'foo', 'put', 'existing_%d' % i,
|
|
|
|
dummyfile2], wait=False)
|
|
|
|
# Remove some soon to be divergent
|
|
|
|
log.info('remove divergent objects')
|
|
|
|
for i in range(DIVERGENT_REMOVE):
|
|
|
|
rados(ctx, mon, ['-p', 'foo', 'rm',
|
|
|
|
'existing_%d' % (i + DIVERGENT_WRITE)], wait=False)
|
2012-11-09 00:22:40 +00:00
|
|
|
time.sleep(10)
|
|
|
|
mon.run(
|
|
|
|
args=['killall', '-9', 'rados'],
|
|
|
|
wait=True,
|
|
|
|
check_status=False)
|
|
|
|
|
2015-05-05 04:13:08 +00:00
|
|
|
# kill all the osds but leave divergent in
|
2012-11-09 00:22:40 +00:00
|
|
|
log.info('killing all the osds')
|
|
|
|
for i in osds:
|
2014-08-15 13:56:52 +00:00
|
|
|
ctx.manager.kill_osd(i)
|
2012-11-09 00:22:40 +00:00
|
|
|
for i in osds:
|
2014-08-15 13:56:52 +00:00
|
|
|
ctx.manager.mark_down_osd(i)
|
2015-05-05 04:13:08 +00:00
|
|
|
for i in non_divergent:
|
2014-08-15 13:56:52 +00:00
|
|
|
ctx.manager.mark_out_osd(i)
|
2012-11-09 00:22:40 +00:00
|
|
|
|
|
|
|
# bring up non-divergent
|
|
|
|
log.info("bringing up non_divergent %s", str(non_divergent))
|
|
|
|
for i in non_divergent:
|
2014-08-15 13:56:52 +00:00
|
|
|
ctx.manager.revive_osd(i)
|
2012-11-09 00:22:40 +00:00
|
|
|
for i in non_divergent:
|
2014-08-15 13:56:52 +00:00
|
|
|
ctx.manager.mark_in_osd(i)
|
2012-11-09 00:22:40 +00:00
|
|
|
|
|
|
|
# write 1 non-divergent object (ensure that old divergent one is divergent)
|
2015-05-05 04:13:08 +00:00
|
|
|
objname = "existing_%d" % (DIVERGENT_WRITE + DIVERGENT_REMOVE)
|
|
|
|
log.info('writing non-divergent object ' + objname)
|
|
|
|
rados(ctx, mon, ['-p', 'foo', 'put', objname, dummyfile2])
|
2012-11-09 00:22:40 +00:00
|
|
|
|
2014-08-15 13:56:52 +00:00
|
|
|
ctx.manager.wait_for_recovery()
|
2012-11-09 00:22:40 +00:00
|
|
|
|
2015-05-05 04:13:08 +00:00
|
|
|
# ensure no recovery of up osds first
|
2012-11-09 00:22:40 +00:00
|
|
|
log.info('delay recovery')
|
|
|
|
for i in non_divergent:
|
2015-05-05 04:13:08 +00:00
|
|
|
ctx.manager.wait_run_admin_socket(
|
|
|
|
'osd', i, ['set_recovery_delay', '100000'])
|
2012-11-09 00:22:40 +00:00
|
|
|
|
|
|
|
# bring in our divergent friend
|
|
|
|
log.info("revive divergent %d", divergent)
|
2015-05-05 04:13:08 +00:00
|
|
|
ctx.manager.raw_cluster_cmd('osd', 'set', 'noup')
|
2014-08-15 13:56:52 +00:00
|
|
|
ctx.manager.revive_osd(divergent)
|
2012-11-09 00:22:40 +00:00
|
|
|
|
2015-05-05 04:13:08 +00:00
|
|
|
log.info('delay recovery divergent')
|
|
|
|
ctx.manager.wait_run_admin_socket(
|
|
|
|
'osd', divergent, ['set_recovery_delay', '100000'])
|
|
|
|
|
|
|
|
ctx.manager.raw_cluster_cmd('osd', 'unset', 'noup')
|
2014-08-15 13:56:52 +00:00
|
|
|
while len(ctx.manager.get_osd_status()['up']) < 3:
|
2012-11-09 00:22:40 +00:00
|
|
|
time.sleep(10)
|
|
|
|
|
|
|
|
log.info('wait for peering')
|
2013-07-22 21:21:51 +00:00
|
|
|
rados(ctx, mon, ['-p', 'foo', 'put', 'foo', dummyfile])
|
2012-11-09 00:22:40 +00:00
|
|
|
|
2015-05-05 04:13:08 +00:00
|
|
|
# At this point the divergent_priors should have been detected
|
|
|
|
|
2012-11-09 00:22:40 +00:00
|
|
|
log.info("killing divergent %d", divergent)
|
2014-08-15 13:56:52 +00:00
|
|
|
ctx.manager.kill_osd(divergent)
|
2012-11-09 00:22:40 +00:00
|
|
|
log.info("reviving divergent %d", divergent)
|
2014-08-15 13:56:52 +00:00
|
|
|
ctx.manager.revive_osd(divergent)
|
2012-11-09 00:22:40 +00:00
|
|
|
|
|
|
|
log.info('allowing recovery')
|
2015-05-05 04:13:08 +00:00
|
|
|
# Set osd_recovery_delay_start back to 0 and kick the queue
|
|
|
|
for i in osds:
|
|
|
|
ctx.manager.raw_cluster_cmd('tell', 'osd.%d' % i, 'debug',
|
|
|
|
'kick_recovery_wq', ' 0')
|
|
|
|
|
|
|
|
log.info('reading divergent objects')
|
|
|
|
for i in range(DIVERGENT_WRITE + DIVERGENT_REMOVE):
|
|
|
|
exit_status = rados(ctx, mon, ['-p', 'foo', 'get', 'existing_%d' % i,
|
2015-09-05 13:25:24 +00:00
|
|
|
'/tmp/existing'])
|
2015-05-05 04:13:08 +00:00
|
|
|
assert exit_status is 0
|
|
|
|
|
|
|
|
(remote,) = ctx.\
|
|
|
|
cluster.only('osd.{o}'.format(o=divergent)).remotes.iterkeys()
|
|
|
|
msg = "dirty_divergent_priors: true, divergent_priors: %d" \
|
|
|
|
% (DIVERGENT_WRITE + DIVERGENT_REMOVE)
|
|
|
|
cmd = 'grep "{msg}" /var/log/ceph/ceph-osd.{osd}.log'\
|
|
|
|
.format(msg=msg, osd=divergent)
|
|
|
|
proc = remote.run(args=cmd, wait=True, check_status=False)
|
|
|
|
assert proc.exitstatus == 0
|
2012-11-09 00:22:40 +00:00
|
|
|
|
|
|
|
log.info("success")
|