]> 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>
Tue, 30 Jan 2018 22:28:17 +0000 (16:28 -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>
src/ceph-volume/ceph_volume/devices/lvm/prepare.py
src/ceph-volume/ceph_volume/util/prepare.py

index 1e0d3c3a982a39198c578eec0585585e3f3498fd..781557bbddec3507da3820d4fb1f2f15bc3fc7b9 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
     )