Bug #24936
Updated by Nathan Cutler almost 6 years ago
source:https://github.com/ceph/ceph/blob/aa158b68f0ae48ea9c9dda03d9ab08770fd19f96/src/ceph-volume/ceph_volume/util/prepare.py in github file line 79,function check_id may check the osd_id whether already used or not,but its return make me confuse If my cluster have osd.0 already,this function would return True,so 0 will be use by the next steps.But if osd_id is available,function's return will return False anyway,this function(check_id) can not work in a right way. <pre>def ``` def check_id(osd_id): """ Checks to see if an osd ID exists or not. Returns True if it does exist, False if it doesn't. :param osd_id: The osd ID to check """ if osd_id is None: return False bootstrap_keyring = '/var/lib/ceph/bootstrap-osd/%s.keyring' % conf.cluster stdout, stderr, returncode = process.call( [ 'ceph', '--cluster', conf.cluster, '--name', 'client.bootstrap-osd', '--keyring', bootstrap_keyring, 'osd', 'tree', '-f', 'json', ], show_command=True ) if returncode != 0: raise RuntimeError('Unable check if OSD id exists: %s' % osd_id) output = json.loads(''.join(stdout).strip()) osds = output['nodes'] return any([str(osd['id']) == str(osd_id) for osd in osds]) </pre> ```