]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/scrub.py
11 from teuthology
import misc
as teuthology
13 log
= logging
.getLogger(__name__
)
15 @contextlib.contextmanager
16 def task(ctx
, config
):
18 Run scrub periodically. Randomly chooses an OSD to scrub.
20 The config should be as follows:
23 frequency: <seconds between scrubs>
24 deep: <bool for deepness>
36 assert isinstance(config
, dict), \
37 'scrub task only accepts a dict for configuration'
39 log
.info('Beginning scrub...')
41 first_mon
= teuthology
.get_first_mon(ctx
, config
)
42 (mon
,) = ctx
.cluster
.only(first_mon
).remotes
.iterkeys()
44 manager
= ceph_manager
.CephManager(
47 logger
=log
.getChild('ceph_manager'),
50 num_osds
= teuthology
.num_instances_of_type(ctx
.cluster
, 'osd')
51 while len(manager
.get_osd_status()['up']) < num_osds
:
54 scrub_proc
= Scrubber(
61 log
.info('joining scrub')
66 Scrubbing is actually performed during initialization
68 def __init__(self
, manager
, config
):
70 Spawn scrubbing thread upon completion.
72 self
.ceph_manager
= manager
73 self
.ceph_manager
.wait_for_clean()
75 osd_status
= self
.ceph_manager
.get_osd_status()
76 self
.osds
= osd_status
['up']
79 if self
.config
is None:
90 log
.info("spawning thread")
92 self
.thread
= gevent
.spawn(self
.do_scrub
)
95 """Scrubbing thread finished"""
100 """Perform the scrub operation"""
101 frequency
= self
.config
.get("frequency", 30)
102 deep
= self
.config
.get("deep", 0)
104 log
.info("stopping %s" % self
.stopping
)
106 while not self
.stopping
:
107 osd
= str(random
.choice(self
.osds
))
114 log
.info('%sbing %s' % (cmd
, osd
))
115 self
.ceph_manager
.raw_cluster_cmd('osd', cmd
, osd
)
117 time
.sleep(frequency
)