From: Andrew Schoen Date: Tue, 30 Jan 2018 21:00:04 +0000 (-0600) Subject: ceph-volume: when reusing an osd ID you must give that id to 'osd new' X-Git-Tag: v12.2.3~20^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c01a2bf515c08ae0a058fdf0fd2ca5f469ed5880;p=ceph.git ceph-volume: when reusing an osd ID you must give that id to 'osd new' If you do not then auth will not be created for the new OSD and the daemon will not be able to start. Signed-off-by: Andrew Schoen (cherry picked from commit 43f699fcbc9f30875f70295e086a4e423008b266) --- diff --git a/src/ceph-volume/ceph_volume/devices/lvm/prepare.py b/src/ceph-volume/ceph_volume/devices/lvm/prepare.py index 7f00ce563469..0ee3d52cad55 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/prepare.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/prepare.py @@ -242,7 +242,7 @@ class Prepare(object): if crush_device_class: secrets['crush_device_class'] = crush_device_class # reuse a given ID if it exists, otherwise create a new ID - self.osd_id = prepare_utils.check_id(args.osd_id) or prepare_utils.create_id(osd_fsid, json.dumps(secrets)) + self.osd_id = prepare_utils.create_id(osd_fsid, json.dumps(secrets), osd_id=args.osd_id) tags = { 'ceph.osd_fsid': osd_fsid, 'ceph.osd_id': self.osd_id, diff --git a/src/ceph-volume/ceph_volume/util/prepare.py b/src/ceph-volume/ceph_volume/util/prepare.py index c72cb5529795..a254f43d9a62 100644 --- a/src/ceph-volume/ceph_volume/util/prepare.py +++ b/src/ceph-volume/ceph_volume/util/prepare.py @@ -47,22 +47,27 @@ def write_keyring(osd_id, secret, keyring_name='keyring', name=None): system.chown(osd_keyring) -def create_id(fsid, json_secrets): +def create_id(fsid, json_secrets, osd_id=None): """ :param fsid: The osd fsid to create, always required :param json_secrets: a json-ready object with whatever secrets are wanted to be passed to the monitor + :param osd_id: Reuse an existing ID from an OSD that's been destroyed, if the + id does not exist in the cluster a new ID will be created """ bootstrap_keyring = '/var/lib/ceph/bootstrap-osd/%s.keyring' % conf.cluster + cmd = [ + 'ceph', + '--cluster', conf.cluster, + '--name', 'client.bootstrap-osd', + '--keyring', bootstrap_keyring, + '-i', '-', + 'osd', 'new', fsid + ] + if check_id(osd_id): + cmd.append(osd_id) stdout, stderr, returncode = process.call( - [ - 'ceph', - '--cluster', conf.cluster, - '--name', 'client.bootstrap-osd', - '--keyring', bootstrap_keyring, - '-i', '-', - 'osd', 'new', fsid - ], + cmd, stdin=json_secrets, show_command=True )