Skip to content

Commit

Permalink
mgr/balancer: less verbose on 'eval' by default; add 'eval-verbose'
Browse files Browse the repository at this point in the history
The verbose output is helpful for debugging and understanding what is
being measured, but most of the time all that you care about is the score.

Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
liewegas committed Nov 1, 2017
1 parent 6513e8b commit 2c300bc
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions src/pybind/mgr/balancer/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,21 @@ class Eval:
def __init__(self, ms):
self.ms = ms

def show(self):
r = self.ms.desc + '\n'
r += 'target_by_root %s\n' % self.target_by_root
r += 'actual_by_pool %s\n' % self.actual_by_pool
r += 'actual_by_root %s\n' % self.actual_by_root
r += 'count_by_pool %s\n' % self.count_by_pool
r += 'count_by_root %s\n' % self.count_by_root
r += 'total_by_pool %s\n' % self.total_by_pool
r += 'total_by_root %s\n' % self.total_by_root
r += 'stats_by_root %s\n' % self.stats_by_root
r += 'score_by_pool %s\n' % self.score_by_pool
r += 'score_by_root %s\n' % self.score_by_root
def show(self, verbose=False):
if verbose:
r = self.ms.desc + '\n'
r += 'target_by_root %s\n' % self.target_by_root
r += 'actual_by_pool %s\n' % self.actual_by_pool
r += 'actual_by_root %s\n' % self.actual_by_root
r += 'count_by_pool %s\n' % self.count_by_pool
r += 'count_by_root %s\n' % self.count_by_root
r += 'total_by_pool %s\n' % self.total_by_pool
r += 'total_by_root %s\n' % self.total_by_root
r += 'stats_by_root %s\n' % self.stats_by_root
r += 'score_by_pool %s\n' % self.score_by_pool
r += 'score_by_root %s\n' % self.score_by_root
else:
r = self.ms.desc + ' '
r += 'score %f (lower is better)\n' % self.score
return r

Expand Down Expand Up @@ -213,6 +216,11 @@ class Module(MgrModule):
"desc": "Evaluate data distribution for the current cluster or specific plan",
"perm": "r",
},
{
"cmd": "balancer eval-verbose name=plan,type=CephString,req=false",
"desc": "Evaluate data distribution for the current cluster or specific plan (verbosely)",
"perm": "r",
},
{
"cmd": "balancer optimize name=plan,type=CephString",
"desc": "Run optimizer to create a new plan",
Expand Down Expand Up @@ -277,7 +285,8 @@ def handle_command(self, command):
self.active = False
self.event.set()
return (0, '', '')
elif command['prefix'] == 'balancer eval':
elif command['prefix'] == 'balancer eval' or command['prefix'] == 'balancer eval-verbose':
verbose = command['prefix'] == 'balancer eval-verbose'
if 'plan' in command:
plan = self.plans.get(command['plan'])
if not plan:
Expand All @@ -288,7 +297,7 @@ def handle_command(self, command):
ms = MappingState(self.get_osdmap(),
self.get("pg_dump"),
'current cluster')
return (0, self.evaluate(ms), '')
return (0, self.evaluate(ms, verbose=verbose), '')
elif command['prefix'] == 'balancer optimize':
plan = self.plan_create(command['plan'])
self.optimize(plan)
Expand Down Expand Up @@ -552,9 +561,9 @@ def calc_eval(self, ms):
pe.score /= 3 * len(roots)
return pe

def evaluate(self, ms):
def evaluate(self, ms, verbose=False):
pe = self.calc_eval(ms)
return pe.show()
return pe.show(verbose=verbose)

def optimize(self, plan):
self.log.info('Optimize plan %s' % plan.name)
Expand Down

0 comments on commit 2c300bc

Please sign in to comment.