From c01a2bf515c08ae0a058fdf0fd2ca5f469ed5880 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Tue, 30 Jan 2018 15:00:04 -0600 Subject: [PATCH] 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) --- .../ceph_volume/devices/lvm/prepare.py | 2 +- src/ceph-volume/ceph_volume/util/prepare.py | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/prepare.py b/src/ceph-volume/ceph_volume/devices/lvm/prepare.py index 7f00ce56346..0ee3d52cad5 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 c72cb552979..a254f43d9a6 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 ) -- 2.47.3