From 4903d06a76fca5a2474ab0487c3e667a07e73a39 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Thu, 9 Jun 2011 12:58:51 -0700 Subject: [PATCH] Archive everything written to the "archive" directory. This avoids listing "log", "profiling-logger", etc individually. Adding new types of archived files should just be a matter of adding a subdirectory under "archive". --- teuthology/ceph.conf | 4 +- teuthology/task/ceph.py | 102 ++++++++++++++++++++-------------------- 2 files changed, 52 insertions(+), 54 deletions(-) diff --git a/teuthology/ceph.conf b/teuthology/ceph.conf index 653f856bc7..0b25a7f958 100644 --- a/teuthology/ceph.conf +++ b/teuthology/ceph.conf @@ -1,8 +1,8 @@ [global] keyring = /tmp/cephtest/ceph.keyring - log file = /tmp/cephtest/log/$name.log + log file = /tmp/cephtest/archive/log/$name.log logger = true - logger dir = /tmp/cephtest/profiling-logger + logger dir = /tmp/cephtest/archive/profiling-logger chdir = "" pid file = $name.pid auth supported = cephx diff --git a/teuthology/task/ceph.py b/teuthology/task/ceph.py index 5d793aa1dc..dbe113216f 100644 --- a/teuthology/task/ceph.py +++ b/teuthology/task/ceph.py @@ -49,8 +49,9 @@ def task(ctx, config): args=[ 'install', '-d', '-m0755', '--', '/tmp/cephtest/binary', - '/tmp/cephtest/log', - '/tmp/cephtest/profiling-logger', + '/tmp/cephtest/archive', + '/tmp/cephtest/archive/log', + '/tmp/cephtest/archive/profiling-logger', '/tmp/cephtest/data', ], wait=False, @@ -449,7 +450,7 @@ def task(ctx, config): ctx.cluster.run( args=[ 'find', - '/tmp/cephtest/log', + '/tmp/cephtest/archive/log', '-name', '*.log', '-print0', @@ -466,62 +467,59 @@ def task(ctx, config): ), ) - log.info('Transferring logs...') - for logtype in ['log', 'profiling-logger']: - logdir = os.path.join(ctx.archive, logtype) - os.mkdir(logdir) - for remote in ctx.cluster.remotes.iterkeys(): - path = os.path.join(logdir, remote.shortname) - os.mkdir(path) - log.debug('Transferring logs for %s from %s to %s', remote.shortname, logtype, path) - proc = remote.run( - args=[ - 'tar', - 'c', - '-f', '-', - '-C', '/tmp/cephtest', - '-C', logtype, - '--', - '.', - ], - stdout=run.PIPE, - wait=False, - ) - tar = tarfile.open(mode='r|', fileobj=proc.stdout) - while True: - ti = tar.next() - if ti is None: - break - - if ti.isdir(): - # ignore silently; easier to just create leading dirs below - pass - elif ti.isfile(): - sub = safepath.munge(ti.name) - safepath.makedirs(root=path, path=os.path.dirname(sub)) - tar.makefile(ti, targetpath=os.path.join(path, sub)) + log.info('Transferring archived files...') + logdir = os.path.join(ctx.archive, 'remote') + os.mkdir(logdir) + for remote in ctx.cluster.remotes.iterkeys(): + path = os.path.join(logdir, remote.shortname) + os.mkdir(path) + log.debug('Transferring archived files from %s to %s', remote.shortname, path) + proc = remote.run( + args=[ + 'tar', + 'c', + '-f', '-', + '-C', '/tmp/cephtest/archive', + '--', + '.', + ], + stdout=run.PIPE, + wait=False, + ) + tar = tarfile.open(mode='r|', fileobj=proc.stdout) + while True: + ti = tar.next() + if ti is None: + break + + if ti.isdir(): + # ignore silently; easier to just create leading dirs below + pass + elif ti.isfile(): + sub = safepath.munge(ti.name) + safepath.makedirs(root=path, path=os.path.dirname(sub)) + tar.makefile(ti, targetpath=os.path.join(path, sub)) + else: + if ti.isdev(): + type_ = 'device' + elif ti.issym(): + type_ = 'symlink' + elif ti.islnk(): + type_ = 'hard link' else: - if ti.isdev(): - type_ = 'device' - elif ti.issym(): - type_ = 'symlink' - elif ti.islnk(): - type_ = 'hard link' - else: - type_ = 'unknown' - log.info('Ignoring tar entry: %r type %r', ti.name, type_) - continue - proc.exitstatus.get() - - log.info('Removing log files...') + type_ = 'unknown' + log.info('Ignoring tar entry: %r type %r', ti.name, type_) + continue + proc.exitstatus.get() + + log.info('Removing archived files...') run.wait( ctx.cluster.run( args=[ 'rm', '-rf', '--', - '/tmp/cephtest/log', - '/tmp/cephtest/profiling-logger', + '/tmp/cephtest/archive', ], wait=False, ), -- 2.39.5