From 1a43c3443b99cee9cd6425551ec08e284875ec40 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Wed, 27 Jun 2012 19:38:12 -0500 Subject: [PATCH] Added blktrace task Signed-off-by: Mark Nelson --- teuthology/task/blktrace.py | 93 +++++++++++++++++++++++++++++++++++++ teuthology/task/ceph.py | 6 ++- 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 teuthology/task/blktrace.py diff --git a/teuthology/task/blktrace.py b/teuthology/task/blktrace.py new file mode 100644 index 0000000000000..1e9aa0b63f827 --- /dev/null +++ b/teuthology/task/blktrace.py @@ -0,0 +1,93 @@ +from cStringIO import StringIO + +import contextlib +import logging +import os +import re +import yaml + +from teuthology import misc as teuthology +from teuthology import contextutil +from ..orchestra import run + +log = logging.getLogger(__name__) +blktrace = '/usr/sbin/blktrace' +log_dir = '/tmp/cephtest/archive/performance/blktrace' + +@contextlib.contextmanager +def setup(ctx, config): + osds = ctx.cluster.only(teuthology.is_type('osd')) + for remote, roles_for_host in osds.remotes.iteritems(): + log.info('Creating %s on %s' % (log_dir,remote.name)) + proc = remote.run( + args=['mkdir', '-p', '-m0755', '--', log_dir], + wait=False, + ) + yield + +@contextlib.contextmanager +def execute(ctx, config): + osds = ctx.cluster.only(teuthology.is_type('osd')) + for remote, roles_for_host in osds.remotes.iteritems(): + roles_to_devs = ctx.disk_config.remote_to_roles_to_dev[remote] + roles_to_journals = ctx.disk_config.remote_to_roles_to_journals[remote] + for id_ in teuthology.roles_of_type(roles_for_host, 'osd'): + if roles_to_devs.get(id_): + dev = roles_to_devs[id_] + log.info("running blktrace on %s: %s" % (remote.name, dev)) + proc = remote.run( + args=[ + 'cd', + log_dir, + run.Raw(';'), + 'sudo', + blktrace, + '-o', + dev.rsplit("/", 1)[1], + '-d', + dev, + ], + wait=False, + ) +# nodes = {} +# for client, properties in config.iteritems(): +# if properties is None: +# properties = {} +# gen_movies = properties.get('gen_movies', 'false') +# +# cluster = ctx.cluster.only(client) +# for remote in cluster.remotes.iterkeys(): +# proc = remote.run( +# args=[ +# os.path.join(bin_dir, 'blktrace'), +# '-t', +# log_dir, +# '-o' +# '%s/%s' % (logdir, device), +# '-F10', +# ], +# wait=False, +# ) +# nodes[remote] = proc + try: + yield + finally: + osds = ctx.cluster.only(teuthology.is_type('osd')) + for remote, roles_for_host in osds.remotes.iteritems(): + log.info('stopping all blktrace processes on %s' % (remote.name)) + remote.run(args=['sudo', 'pkill', '-f', 'blktrace']) + +@contextlib.contextmanager +def task(ctx, config): + if config is None: + config = dict(('client.{id}'.format(id=id_), None) + for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client')) + elif isinstance(config, list): + config = dict.fromkeys(config) + + with contextutil.nested( + lambda: setup(ctx=ctx, config=config), + lambda: execute(ctx=ctx, config=config), + ): + yield + diff --git a/teuthology/task/ceph.py b/teuthology/task/ceph.py index 96a1d87730618..2d9c755801210 100644 --- a/teuthology/task/ceph.py +++ b/teuthology/task/ceph.py @@ -335,7 +335,7 @@ def cluster(ctx, config): devs = devs[len(roles_to_devs):] log.info('dev map: %s' % (str(roles_to_devs),)) devs_to_clean[remote] = [] - + if config.get('block_journal'): log.info('block journal enabled') roles_to_journals = assign_devs( @@ -598,6 +598,10 @@ def cluster(ctx, config): for remote, roles_for_host in osds.remotes.iteritems(): roles_to_devs = remote_to_roles_to_devs[remote] roles_to_journals = remote_to_roles_to_journals[remote] + ctx.disk_config = argparse.Namespace() + ctx.disk_config.remote_to_roles_to_dev = remote_to_roles_to_devs + ctx.disk_config.remote_to_roles_to_journals = remote_to_roles_to_journals + for id_ in teuthology.roles_of_type(roles_for_host, 'osd'): log.info(str(roles_to_journals)) log.info(id_) -- 2.39.5