From d09ae0b280025cc22916441672e7a14455437425 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Fri, 10 Jun 2011 11:18:13 -0700 Subject: [PATCH] With coverage, use SIGTERM to make the daemons exit(0). --- teuthology/task/ceph.py | 40 ++++++++++++++--------------------- teuthology/task/cfuse.py | 1 + teuthology/task/daemon-helper | 8 +++++-- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/teuthology/task/ceph.py b/teuthology/task/ceph.py index b09124666b..1e731621f4 100644 --- a/teuthology/task/ceph.py +++ b/teuthology/task/ceph.py @@ -54,9 +54,11 @@ def task(ctx, config): "task ceph only supports a dictionary for configuration" flavor = None + daemon_signal = 'kill' if config.get('coverage'): log.info('Recording coverage for this run.') flavor = 'gcov' + daemon_signal = 'term' log.info('Checking for old test directory...') processes = ctx.cluster.run( @@ -283,6 +285,7 @@ def task(ctx, config): '/tmp/cephtest/binary/usr/local/bin/ceph-coverage', coverage_dir, '/tmp/cephtest/daemon-helper', + daemon_signal, '/tmp/cephtest/binary/usr/local/bin/cmon', '-f', '-i', id_, @@ -439,6 +442,7 @@ def task(ctx, config): '/tmp/cephtest/binary/usr/local/bin/ceph-coverage', coverage_dir, '/tmp/cephtest/daemon-helper', + daemon_signal, '/tmp/cephtest/binary/usr/local/bin/cosd', '-f', '-i', id_, @@ -459,6 +463,7 @@ def task(ctx, config): '/tmp/cephtest/binary/usr/local/bin/ceph-coverage', coverage_dir, '/tmp/cephtest/daemon-helper', + daemon_signal, '/tmp/cephtest/binary/usr/local/bin/cmds', '-f', '-i', id_, @@ -479,30 +484,17 @@ def task(ctx, config): try: yield finally: - if config.get('coverage'): - # need to exit cleanly to trigger atexit coverage data writing - log.info('Shutting down everything, gcov style...') - mon0_remote.run( - args=[ - '/tmp/cephtest/binary/usr/local/bin/ceph-coverage', - coverage_dir, - '/tmp/cephtest/binary/usr/local/bin/ceph', - '-c', '/tmp/cephtest/ceph.conf', - 'all_exit' - ] - ) - else: - log.info('Shutting down mds daemons...') - for id_, proc in mds_daemons.iteritems(): - proc.stdin.close() - - log.info('Shutting down osd daemons...') - for id_, proc in osd_daemons.iteritems(): - proc.stdin.close() - - log.info('Shutting down mon daemons...') - for id_, proc in mon_daemons.iteritems(): - proc.stdin.close() + log.info('Shutting down mds daemons...') + for id_, proc in mds_daemons.iteritems(): + proc.stdin.close() + + log.info('Shutting down osd daemons...') + for id_, proc in osd_daemons.iteritems(): + proc.stdin.close() + + log.info('Shutting down mon daemons...') + for id_, proc in mon_daemons.iteritems(): + proc.stdin.close() run.wait(mds_daemons.itervalues()) run.wait(osd_daemons.itervalues()) diff --git a/teuthology/task/cfuse.py b/teuthology/task/cfuse.py index e9fd52a247..31553378b7 100644 --- a/teuthology/task/cfuse.py +++ b/teuthology/task/cfuse.py @@ -45,6 +45,7 @@ def task(ctx, config): '/tmp/cephtest/binary/usr/local/bin/ceph-coverage', '/tmp/cephtest/archive/coverage', '/tmp/cephtest/daemon-helper', + 'kill', '/tmp/cephtest/binary/usr/local/bin/cfuse', '-f', '--name', 'client.{id}'.format(id=id_), diff --git a/teuthology/task/daemon-helper b/teuthology/task/daemon-helper index a44fb4514c..4a044cbe79 100755 --- a/teuthology/task/daemon-helper +++ b/teuthology/task/daemon-helper @@ -21,9 +21,13 @@ import signal import subprocess import sys +end_signal = signal.SIGKILL +if sys.argv[1] == "term": + end_signal = signal.SIGTERM + with file('/dev/null', 'rb') as devnull: proc = subprocess.Popen( - args=sys.argv[1:], + args=sys.argv[2:], stdin=devnull, ) @@ -37,7 +41,7 @@ while True: data = os.read(0, 1) if not data: saw_eof = True - proc.send_signal(signal.SIGKILL) + proc.send_signal(end_signal) break if proc.poll() is not None: -- 2.39.5