]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
ceph_ansible: Don't collect logs on non-Ceph hosts
authorZack Cerza <zack@redhat.com>
Thu, 19 Oct 2017 18:32:07 +0000 (12:32 -0600)
committerZack Cerza <zack@redhat.com>
Fri, 20 Oct 2017 18:06:20 +0000 (12:06 -0600)
If a job uses machines for something other than to install Ceph, avoid
attempting to collect Ceph logs - the job will fail.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/task/ceph_ansible.py

index dd5a04996e69b7fd30096d882edc852b0939acf5..9c95bf80bf5765fc7f580c1627741c8bdbf49728 100644 (file)
@@ -42,6 +42,15 @@ class CephAnsible(Task):
         * Set ``public_network`` for each host if ``public_network`` is unset
     """.format(git_base=teuth_config.ceph_git_base_url)
 
+    groups_to_roles = dict(
+        mons='mon',
+        mgrs='mgr',
+        mdss='mds',
+        osds='osd',
+        rgws='rgw',
+        clients='client',
+    )
+
     def __init__(self, ctx, config):
         super(CephAnsible, self).__init__(ctx, config)
         config = self.config or dict()
@@ -114,17 +123,9 @@ class CephAnsible(Task):
             self.run_playbook()
 
     def generate_hosts_file(self):
-        groups_to_roles = dict(
-            mons='mon',
-            mgrs='mgr',
-            mdss='mds',
-            osds='osd',
-            rgws='rgw',
-            clients='client',
-        )
         hosts_dict = dict()
-        for group in sorted(groups_to_roles.keys()):
-            role_prefix = groups_to_roles[group]
+        for group in sorted(self.groups_to_roles.keys()):
+            role_prefix = self.groups_to_roles[group]
             want = lambda role: role.startswith(role_prefix)
             for (remote, roles) in self.cluster.only(want).remotes.iteritems():
                 hostname = remote.hostname
@@ -261,7 +262,15 @@ class CephAnsible(Task):
             log.info('Archiving logs...')
             path = os.path.join(ctx.archive, 'remote')
             os.makedirs(path)
-            for remote in ctx.cluster.remotes.iterkeys():
+
+            def wanted(role):
+                # Only attempt to collect logs from hosts which are part of the
+                # cluster
+                return any(map(
+                    lambda role_stub: role.startswith(role_stub),
+                    self.groups_to_roles.values(),
+                ))
+            for remote in ctx.cluster.only(wanted).remotes.keys():
                 sub = os.path.join(path, remote.shortname)
                 os.makedirs(sub)
                 misc.pull_directory(remote, '/var/log/ceph',