From: Loic Dachary Date: Mon, 10 Apr 2017 20:49:14 +0000 (+0200) Subject: mon: set-device-class implicitly creates OSD X-Git-Tag: v12.0.2~26^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7c2fbca0df36e8482ac2f2be4152676ef58284d5;p=ceph.git mon: set-device-class implicitly creates OSD If the OSD does not exist in the crushmap, it is implicitly created. Signed-off-by: Loic Dachary --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 3d513e787bc..95124c74bf5 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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)