From 7e21ce2d9752f4e3c5156271a707e2056a8f684e Mon Sep 17 00:00:00 2001 From: Vasu Kulkarni Date: Fri, 25 May 2018 01:04:08 -0400 Subject: [PATCH] detect osd id's and use them in new roles as ansible can change the order of osd's that are bootstrapped Signed-off-by: Vasu Kulkarni --- teuthology/task/ceph_ansible.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/teuthology/task/ceph_ansible.py b/teuthology/task/ceph_ansible.py index eee9e5250a..5dcd9bc04c 100644 --- a/teuthology/task/ceph_ansible.py +++ b/teuthology/task/ceph_ansible.py @@ -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 \ -- 2.39.5