4 from teuthology
.orchestra
import run
7 from teuthology
import misc
as teuthology
8 from util
.rados
import rados
11 log
= logging
.getLogger(__name__
)
13 def task(ctx
, config
):
15 Test handling of lost objects on an ec pool.
17 A pretty rigid cluster is brought up andtested by this task
21 assert isinstance(config
, dict), \
22 'lost_unfound task only accepts a dict for configuration'
23 first_mon
= teuthology
.get_first_mon(ctx
, config
)
24 (mon
,) = ctx
.cluster
.only(first_mon
).remotes
.iterkeys()
26 manager
= ceph_manager
.CephManager(
29 logger
=log
.getChild('ceph_manager'),
32 manager
.wait_for_clean()
34 profile
= config
.get('erasure_code_profile', {
37 'ruleset-failure-domain': 'osd'
39 profile_name
= profile
.get('name', 'lost_unfound')
40 manager
.create_erasure_code_profile(profile_name
, profile
)
41 pool
= manager
.create_pool_with_unique_name(
42 erasure_code_profile_name
=profile_name
,
45 # something that is always there, readable and never empty
46 dummyfile
= '/etc/group'
48 # kludge to make sure they get a map
49 rados(ctx
, mon
, ['-p', pool
, 'put', 'dummy', dummyfile
])
51 manager
.flush_pg_stats([0, 1])
52 manager
.wait_for_recovery()
55 for f
in range(1, 10):
56 rados(ctx
, mon
, ['-p', pool
, 'put', 'existing_%d' % f
, dummyfile
])
57 rados(ctx
, mon
, ['-p', pool
, 'put', 'existed_%d' % f
, dummyfile
])
58 rados(ctx
, mon
, ['-p', pool
, 'rm', 'existed_%d' % f
])
60 # delay recovery, and make the pg log very long (to prevent backfill)
61 manager
.raw_cluster_cmd(
64 '--osd-recovery-delay-start 1000 --osd-min-pg-log-entries 100000000'
68 manager
.mark_down_osd(0)
70 manager
.mark_down_osd(3)
72 for f
in range(1, 10):
73 rados(ctx
, mon
, ['-p', pool
, 'put', 'new_%d' % f
, dummyfile
])
74 rados(ctx
, mon
, ['-p', pool
, 'put', 'existed_%d' % f
, dummyfile
])
75 rados(ctx
, mon
, ['-p', pool
, 'put', 'existing_%d' % f
, dummyfile
])
77 # take out osd.1 and a necessary shard of those objects.
79 manager
.mark_down_osd(1)
80 manager
.raw_cluster_cmd('osd', 'lost', '1', '--yes-i-really-mean-it')
82 manager
.wait_till_osd_is_up(0)
84 manager
.wait_till_osd_is_up(3)
86 manager
.flush_pg_stats([0, 2, 3])
87 manager
.wait_till_active()
88 manager
.flush_pg_stats([0, 2, 3])
90 # verify that there are unfound objects
91 unfound
= manager
.get_num_unfound_objects()
92 log
.info("there are %d unfound objects" % unfound
)
95 testdir
= teuthology
.get_testdir(ctx
)
97 if config
.get('parallel_bench', True):
101 " ".join(['adjust-ulimits',
103 '{tdir}/archive/coverage',
105 '--no-log-to-stderr',
106 '--name', 'client.admin',
110 'bench', '240', 'write',
111 ]).format(tdir
=testdir
),
113 logger
=log
.getChild('radosbench.{id}'.format(id='client.admin')),
120 pgs
= manager
.get_pg_stats()
122 if pg
['stat_sum']['num_objects_unfound'] > 0:
123 # verify that i can list them direct from the osd
124 log
.info('listing missing/lost in %s state %s', pg
['pgid'],
126 m
= manager
.list_pg_missing(pg
['pgid'])
128 assert m
['num_unfound'] == pg
['stat_sum']['num_objects_unfound']
130 log
.info("reverting unfound in %s", pg
['pgid'])
131 manager
.raw_cluster_cmd('pg', pg
['pgid'],
132 'mark_unfound_lost', 'delete')
134 log
.info("no unfound in %s", pg
['pgid'])
136 manager
.raw_cluster_cmd('tell', 'osd.0', 'debug', 'kick_recovery_wq', '5')
137 manager
.raw_cluster_cmd('tell', 'osd.2', 'debug', 'kick_recovery_wq', '5')
138 manager
.raw_cluster_cmd('tell', 'osd.3', 'debug', 'kick_recovery_wq', '5')
139 manager
.flush_pg_stats([0, 2, 3])
140 manager
.wait_for_recovery()
142 if not config
.get('parallel_bench', True):
146 for f
in range(1, 10):
147 err
= rados(ctx
, mon
, ['-p', pool
, 'get', 'new_%d' % f
, '-'])
149 err
= rados(ctx
, mon
, ['-p', pool
, 'get', 'existed_%d' % f
, '-'])
151 err
= rados(ctx
, mon
, ['-p', pool
, 'get', 'existing_%d' % f
, '-'])
154 # see if osd.1 can cope
155 manager
.revive_osd(1)
156 manager
.wait_till_osd_is_up(1)
157 manager
.wait_for_clean()