Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Thrasher: update pgp_num of all expanded pools if not yet #13367

Merged
merged 4 commits into from Feb 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 46 additions & 9 deletions qa/tasks/ceph_manager.py
Expand Up @@ -112,6 +112,7 @@ def __init__(self, manager, config, logger=None):
self.logger = logger
self.config = config
self.revive_timeout = self.config.get("revive_timeout", 150)
self.pools_to_fix_pgp_num = set()
if self.config.get('powercycle'):
self.revive_timeout += 120
self.clean_wait = self.config.get('clean_wait', 0)
Expand All @@ -137,12 +138,13 @@ def tmp(x):
self.config = dict()
# prevent monitor from auto-marking things out while thrasher runs
# try both old and new tell syntax, in case we are testing old code
try:
manager.raw_cluster_cmd('--', 'tell', 'mon.*', 'injectargs',
'--mon-osd-down-out-interval 0')
except Exception:
manager.raw_cluster_cmd('--', 'mon', 'tell', '*', 'injectargs',
'--mon-osd-down-out-interval 0')
self.saved_options = {}
first_mon = teuthology.get_first_mon(manager.ctx, self.config).split('.')
opt_name = 'mon_osd_down_out_interval'
self.saved_options[opt_name] = manager.get_config(first_mon[0],
first_mon[1],
opt_name)
self._set_config('mon', '*', opt_name, 0)
# initialize ceph_objectstore_tool property - must be done before
# do_thrash is spawned - http://tracker.ceph.com/issues/18799
if (self.config.get('powercycle') or
Expand Down Expand Up @@ -172,6 +174,18 @@ def tmp(x):
if self.noscrub_toggle_delay:
self.noscrub_toggle_thread = gevent.spawn(self.do_noscrub_toggle)

def _set_config(self, service_type, service_id, name, value):
opt_arg = '--{name} {value}'.format(name=name, value=value)
try:
whom = '.'.join([service_type, service_id])
self.ceph_manager.raw_cluster_cmd('--', 'tell', whom,
'injectargs', opt_arg)
except Exception:
self.ceph_manager.raw_cluster_cmd('--', service_type,
'tell', service_id,
'injectargs', opt_arg)


def cmd_exists_on_osds(self, cmd):
allremotes = self.ceph_manager.ctx.cluster.only(\
teuthology.is_type('osd', self.cluster)).remotes.keys()
Expand Down Expand Up @@ -515,18 +529,24 @@ def grow_pool(self):
Increase the size of the pool
"""
pool = self.ceph_manager.get_pool()
orig_pg_num = self.ceph_manager.get_pool_pg_num(pool)
self.log("Growing pool %s" % (pool,))
self.ceph_manager.expand_pool(pool,
self.config.get('pool_grow_by', 10),
self.max_pgs)
if orig_pg_num < self.ceph_manager.get_pool_pg_num(pool):
self.pools_to_fix_pgp_num.add(pool)

def fix_pgp_num(self):
def fix_pgp_num(self, pool=None):
"""
Fix number of pgs in pool.
"""
pool = self.ceph_manager.get_pool()
if pool is None:
pool = self.ceph_manager.get_pool()
self.log("fixing pg num pool %s" % (pool,))
self.ceph_manager.set_pool_pgpnum(pool)
if pool in self.pools_to_fix_pgp_num:
self.pools_to_fix_pgp_num.remove(pool)

def test_pool_min_size(self):
"""
Expand Down Expand Up @@ -839,6 +859,13 @@ def do_thrash(self):
Scrubber(self.ceph_manager, self.config)
self.choose_action()()
time.sleep(delay)
for pool in list(self.pools_to_fix_pgp_num):
if self.ceph_manager.get_pool_pg_num(pool) > 0:
self.fix_pgp_num(pool)
self.pools_to_fix_pgp_num.clear()
for opt, value in self.saved_options.iteritems():
self._set_config('mon', '*', opt, value)
self.saved_options.clear()
self.all_up()


Expand Down Expand Up @@ -1235,7 +1262,7 @@ def wait_run_admin_socket(self, service_type,
proc = self.admin_socket(service_type, service_id,
args, check_status=False, stdout=stdout)
if proc.exitstatus is 0:
break
return proc
else:
tries += 1
if (tries * 5) > timeout:
Expand All @@ -1259,6 +1286,16 @@ def get_pool_dump(self, pool):
return i
assert False

def get_config(self, service_type, service_id, name):
"""
:param node: like 'mon.a'
:param name: the option name
"""
proc = self.wait_run_admin_socket(service_type, service_id,
['config', 'show'])
j = json.loads(proc.stdout.getvalue())
return j[name]

def set_config(self, osdnum, **argdict):
"""
:param osdnum: osd number
Expand Down