]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph: archive logs at very end
authorSage Weil <sage@redhat.com>
Sat, 21 Feb 2015 00:54:09 +0000 (16:54 -0800)
committerSage Weil <sage@redhat.com>
Tue, 24 Feb 2015 01:00:57 +0000 (17:00 -0800)
This ensures that we still gather the logs even if the other nested tasks
throw an exception in the finally block.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit ca09683f5fc1a6067c524c4034c27ab4a26e11f3)

tasks/ceph.py

index cc8a59abe109dfb3b779becd4bda0a04ee4ba89c..589dcb1eb5f8cf9d32fe9decb66384c3ea198fe3 100644 (file)
@@ -76,7 +76,40 @@ def ceph_log(ctx, config):
         yield
 
     finally:
-        pass
+        if ctx.archive is not None and \
+                not (ctx.config.get('archive-on-error') and ctx.summary['success']):
+            # and logs
+            log.info('Compressing logs...')
+            run.wait(
+                ctx.cluster.run(
+                    args=[
+                        'sudo',
+                        'find',
+                        '/var/log/ceph',
+                        '-name',
+                        '*.log',
+                        '-print0',
+                        run.Raw('|'),
+                        'sudo',
+                        'xargs',
+                        '-0',
+                        '--no-run-if-empty',
+                        '--',
+                        'gzip',
+                        '--',
+                        ],
+                    wait=False,
+                    ),
+                )
+
+            log.info('Archiving logs...')
+            path = os.path.join(ctx.archive, 'remote')
+            os.makedirs(path)
+            for remote in ctx.cluster.remotes.iterkeys():
+                sub = os.path.join(path, remote.shortname)
+                os.makedirs(sub)
+                teuthology.pull_directory(remote, '/var/log/ceph',
+                                          os.path.join(sub, 'log'))
 
 
 def assign_devs(roles, devs):
@@ -748,7 +781,8 @@ def cluster(ctx, config):
                 )
 
         if ctx.archive is not None and \
-                not (ctx.config.get('archive-on-error') and ctx.summary['success']):
+           not (ctx.config.get('archive-on-error') and ctx.summary['success']):
+
             # archive mon data, too
             log.info('Archiving mon data...')
             path = os.path.join(ctx.archive, 'data')
@@ -761,40 +795,6 @@ def cluster(ctx, config):
                             '/var/lib/ceph/mon',
                             path + '/' + role + '.tgz')
 
-            # and logs
-            log.info('Compressing logs...')
-            run.wait(
-                ctx.cluster.run(
-                    args=[
-                        'sudo',
-                        'find',
-                        '/var/log/ceph',
-                        '-name',
-                        '*.log',
-                        '-print0',
-                        run.Raw('|'),
-                        'sudo',
-                        'xargs',
-                        '-0',
-                        '--no-run-if-empty',
-                        '--',
-                        'gzip',
-                        '--',
-                        ],
-                    wait=False,
-                    ),
-                )
-
-            log.info('Archiving logs...')
-            path = os.path.join(ctx.archive, 'remote')
-            os.makedirs(path)
-            for remote in ctx.cluster.remotes.iterkeys():
-                sub = os.path.join(path, remote.shortname)
-                os.makedirs(sub)
-                teuthology.pull_directory(remote, '/var/log/ceph',
-                                          os.path.join(sub, 'log'))
-
-
         log.info('Cleaning ceph cluster...')
         run.wait(
             ctx.cluster.run(