]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/cephadm: tear down clsuter before gathering logs
authorSage Weil <sage@newdream.net>
Thu, 15 Apr 2021 22:55:00 +0000 (17:55 -0500)
committerSage Weil <sage@newdream.net>
Fri, 23 Apr 2021 12:24:15 +0000 (07:24 -0500)
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 <sage@newdream.net>
(cherry picked from commit deec9074bb2fc42d29d6fa14c22b6b14b97c352f)

qa/tasks/cephadm.py
src/cephadm/cephadm

index 721b4b0871bb16924e39b65e51f5382edf6f1a64..15380088ca93781111b50aacef6819c14e5b63ad 100644 (file)
@@ -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',
index 849c696888c7f0ddec88f61c00ce16daf2af7dc6..601b8f4a6dadafac47a3892d198f2891feede1ed 100755 (executable)
@@ -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')