From 7c2fbca0df36e8482ac2f2be4152676ef58284d5 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Mon, 10 Apr 2017 22:49:14 +0200 Subject: [PATCH] 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 --- src/mon/OSDMonitor.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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) -- 2.47.3