]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: set-device-class implicitly creates OSD
authorLoic Dachary <ldachary@redhat.com>
Mon, 10 Apr 2017 20:49:14 +0000 (22:49 +0200)
committerLoic Dachary <ldachary@redhat.com>
Mon, 10 Apr 2017 20:55:22 +0000 (22:55 +0200)
If the OSD does not exist in the crushmap, it is implicitly created.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/mon/OSDMonitor.cc

index 3d513e787bc72d71ca585247d849e6c329bd7e80..95124c74bf5598ff7dc43a1d9871eef15db5043f 100644 (file)
@@ -6202,18 +6202,19 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
       goto reply;
     }
 
-    if (!_get_stable_crush().item_exists(osdid)) {
-      err = -ENOENT;
-      ss << "unable to set-device-class for item id " << osdid << " name '" << name
-         << "' device_class " << device_class << ": does not exist";
-      goto reply;
-    }
-
-    dout(5) << "updating crush item id " << osdid << " name '"
-           << name << "' device_class " << device_class << dendl;
     CrushWrapper newcrush;
     _get_pending_crush(newcrush);
 
+    string action;
+    if (newcrush.item_exists(osdid)) {
+      action = "updating";
+    } else {
+      action = "creating";
+      newcrush.set_item_name(osdid, name);
+    }
+
+    dout(5) << action << " crush item id " << osdid << " name '"
+           << name << "' device_class " << device_class << dendl;
     err = newcrush.update_device_class(g_ceph_context, osdid, device_class, name);
 
     if (err < 0)