]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
detect osd id's and use them in new roles as ansible can change the order
authorVasu Kulkarni <vasu@redhat.com>
Fri, 25 May 2018 05:04:08 +0000 (01:04 -0400)
committerVasu Kulkarni <vasu@redhat.com>
Thu, 14 Feb 2019 20:28:12 +0000 (12:28 -0800)
of osd's that are bootstrapped

Signed-off-by: Vasu Kulkarni <vasu@redhat.com>
teuthology/task/ceph_ansible.py

index eee9e5250ab65bd2ed0ae6cff13e9da87652240a..5dcd9bc04c33a9752c1de23f69813a7d3cd06500 100644 (file)
@@ -386,12 +386,8 @@ class CephAnsible(Task):
                 run.Raw(';'),
                 run.Raw(str_args)
             ],
-            timeout=4200,
-            stdout=out
+            timeout=4200
         )
-        if re.search(r'all hosts have already failed', out.getvalue()):
-            log.error("Failed during ceph-ansible execution")
-            raise CephAnsibleError("Failed during ceph-ansible execution")
         self._create_rbd_pool()
         self._fix_roles_map()
         # fix keyring permission for workunits
@@ -532,10 +528,30 @@ class CephAnsible(Task):
         new_remote_role = dict()
         for remote, roles in ctx.cluster.remotes.iteritems():
             new_remote_role[remote] = []
+            generate_osd_list = True
             for role in roles:
                 _, rol, id = misc.split_role(role)
                 if role.startswith('osd'):
                     new_remote_role[remote].append(role)
+                    if generate_osd_list:
+                        # gather osd ids as seen on host
+                        out = StringIO()
+                        remote.run(args=[
+                                        'ps', '-eaf', run.Raw('|'), 'grep',
+                                        'ceph-osd', run.Raw('|'),
+                                        run.Raw('awk {\'print $13\'}')],
+                                   stdout=out)
+                        osd_list_all = out.getvalue().split('\n')
+                        generate_osd_list = False
+                        osd_list = []
+                        for osd_id in osd_list_all:
+                            try:
+                                osd_num = int(osd_id)
+                                osd_list.append(osd_id)
+                            except ValueError:
+                                # ignore any empty lines as part of output
+                                pass
+                    id = osd_list.pop()
                     log.info("Registering Daemon {rol} {id}".format(rol=rol, id=id))
                     ctx.daemons.add_daemon(remote, rol, id)
                 elif role.startswith('mon') or role.startswith('mgr') or \