]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: when reusing an osd ID you must give that id to 'osd new'
authorAndrew Schoen <aschoen@redhat.com>
Tue, 30 Jan 2018 21:00:04 +0000 (15:00 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Mon, 5 Feb 2018 15:14:20 +0000 (09:14 -0600)
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 <aschoen@redhat.com>
(cherry picked from commit 43f699fcbc9f30875f70295e086a4e423008b266)

src/ceph-volume/ceph_volume/devices/lvm/prepare.py
src/ceph-volume/ceph_volume/util/prepare.py

index 7f00ce56346921bd0453d5c3f884768371174556..0ee3d52cad55353adf42eb4f6a5d0aa4fdf6c495 100644 (file)
@@ -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,
index c72cb552979502f4a8743e6448d41edbc5f3b6fc..a254f43d9a624c5fe7a1907cfab5dd00eb9fe750 100644 (file)
@@ -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
     )