From: Tommi Virtanen Date: Thu, 16 Jun 2011 20:13:32 +0000 (-0700) Subject: Refactor ceph log handling into a separate subtask. X-Git-Tag: v0.94.10~27^2^2~364^2~1717 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=594a3d3f049c753d24e74d2d96b46c4d4a377215;p=ceph.git Refactor ceph log handling into a separate subtask. --- diff --git a/teuthology/task/ceph.py b/teuthology/task/ceph.py index 538a5d941159..698dacd4ebd0 100644 --- a/teuthology/task/ceph.py +++ b/teuthology/task/ceph.py @@ -14,6 +14,50 @@ from orchestra import run log = logging.getLogger(__name__) +@contextlib.contextmanager +def ceph_log(ctx, config): + log.info('Creating log directories...') + run.wait( + ctx.cluster.run( + args=[ + 'install', '-d', '-m0755', '--', + '/tmp/cephtest/archive/log', + '/tmp/cephtest/archive/profiling-logger', + ], + wait=False, + ) + ) + + try: + yield + finally: + + if ctx.archive is not None: + log.info('Compressing logs...') + run.wait( + ctx.cluster.run( + args=[ + 'find', + '/tmp/cephtest/archive/log', + '-name', + '*.log', + '-print0', + run.Raw('|'), + 'xargs', + '-0', + '--no-run-if-empty', + '--', + 'bzip2', + '-9', + '--', + ], + wait=False, + ), + ) + + # log file transfer is done by the generic archive data + # handling + @contextlib.contextmanager def ship_utilities(ctx, config): assert config is None @@ -584,8 +628,6 @@ def task(ctx, config): args=[ 'install', '-d', '-m0755', '--', '/tmp/cephtest/archive', - '/tmp/cephtest/archive/log', - '/tmp/cephtest/archive/profiling-logger', '/tmp/cephtest/data', coverage_dir, ], @@ -594,6 +636,7 @@ def task(ctx, config): ) with contextutil.nested( + lambda: ceph_log(ctx=ctx, config=None), lambda: ship_utilities(ctx=ctx, config=None), lambda: binaries(ctx=ctx, config=dict( branch=config.get('branch'), @@ -616,27 +659,6 @@ def task(ctx, config): yield if ctx.archive is not None: - log.info('Compressing logs...') - run.wait( - ctx.cluster.run( - args=[ - 'find', - '/tmp/cephtest/archive/log', - '-name', - '*.log', - '-print0', - run.Raw('|'), - 'xargs', - '-0', - '--no-run-if-empty', - '--', - 'bzip2', - '-9', - '--', - ], - wait=False, - ), - ) log.info('Transferring archived files...') logdir = os.path.join(ctx.archive, 'remote')