From c9c14b42f355548068dd6feb37080d2416ea51bb Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 15 Apr 2021 17:55:00 -0500 Subject: [PATCH] qa/tasks/cephadm: tear down clsuter before gathering logs We dont' always stop all services, because teuthology doesn't know about things it didn't start. Use rm-cluster to tear things down, but do not remove the logs themselves. After we get logs, we'll clean up completely. Signed-off-by: Sage Weil (cherry picked from commit deec9074bb2fc42d29d6fa14c22b6b14b97c352f) --- qa/tasks/cephadm.py | 12 +++++++++++- src/cephadm/cephadm | 15 +++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/qa/tasks/cephadm.py b/qa/tasks/cephadm.py index 721b4b0871bb1..15380088ca937 100644 --- a/qa/tasks/cephadm.py +++ b/qa/tasks/cephadm.py @@ -471,7 +471,7 @@ def ceph_bootstrap(ctx, config): # this doesn't block until they are all stopped... #ctx.cluster.run(args=['sudo', 'systemctl', 'stop', 'ceph.target']) - # so, stop them individually + # stop the daemons we know for role in ctx.daemons.resolve_role_list(None, CEPH_ROLE_TYPES, True): cluster, type_, id_ = teuthology.split_role(role) try: @@ -480,6 +480,16 @@ def ceph_bootstrap(ctx, config): log.exception(f'Failed to stop "{role}"') raise + # tear down anything left (but leave the logs behind) + ctx.cluster.run(args=[ + 'sudo', + ctx.cephadm, + 'rm-cluster', + '--fsid', fsid, + '--force', + '--keep-logs', + ]) + # clean up /etc/ceph ctx.cluster.run(args=[ 'sudo', 'rm', '-f', diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 849c696888c7f..601b8f4a6dada 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -5385,10 +5385,13 @@ def command_rm_cluster(ctx): ctx.unit_dir + '/ceph-%s.target.wants' % ctx.fsid]) # rm data call_throws(ctx, ['rm', '-rf', ctx.data_dir + '/' + ctx.fsid]) - # rm logs - call_throws(ctx, ['rm', '-rf', ctx.log_dir + '/' + ctx.fsid]) - call_throws(ctx, ['rm', '-rf', ctx.log_dir + # noqa: W504 - '/*.wants/ceph-%s@*' % ctx.fsid]) + + if not ctx.keep_logs: + # rm logs + call_throws(ctx, ['rm', '-rf', ctx.log_dir + '/' + ctx.fsid]) + call_throws(ctx, ['rm', '-rf', ctx.log_dir + # noqa: W504 + '/*.wants/ceph-%s@*' % ctx.fsid]) + # rm logrotate config call_throws(ctx, ['rm', '-f', ctx.logrotate_dir + '/ceph-%s' % ctx.fsid]) @@ -7478,6 +7481,10 @@ def _get_parser(): '--force', action='store_true', help='proceed, even though this may destroy valuable data') + parser_rm_cluster.add_argument( + '--keep-logs', + action='store_true', + help='do not remove log files') parser_run = subparsers.add_parser( 'run', help='run a ceph daemon, in a container, in the foreground') -- 2.39.5