Bug #38789
openceph-volume lvm create --bluestore does not appear to respect or use --osd-id value
0%
Description
When trying to specify an OSD ID through:
ceph-volume lvm create --bluestore --data ${VOLUME} --osd-id ${ID}
The ID passed to '--osd-id' appears to be largely ignored. The created OSD simply uses the unused OSD ID in sequence.
Updated by dovefi Z about 5 years ago
Jamin Collins wrote:
When trying to specify an OSD ID through:
ceph-volume lvm create --bluestore --data ${VOLUME} --osd-id ${ID}
The ID passed to '--osd-id' appears to be largely ignored. The created OSD simply uses the unused OSD ID in sequence.
I also encountered this problem. after i read the code, i found the reason, the "--osd-id" option can be used only when there is an osd which status is destory. may be this is an on purpose design,but i don`t why. source code
src/ceph_volume/util/prepare.py
def osd_id_available(osd_id): """ Checks to see if an osd ID exists and if it's available for reuse. Returns True if it is, False if it isn'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'] osd = [osd for osd in osds if str(osd['id']) == str(osd_id)] if osd and osd[0].get('status') == "destroyed": # this is the reason return True return False
may be it shoud change to
osd = [osd for osd in osds if str(osd['id']) == str(osd_id)] if not osd: # return True when the osd_id is not exist in the cluster return True if osd and osd[0].get('status') == "destroyed": # this is the reason return True return False
this is what i do, and it work.