From: luo rixin Date: Wed, 26 Apr 2023 09:07:55 +0000 (+0800) Subject: crimson/osd: add crush_location_hook feature to crimson X-Git-Tag: v18.1.2~64^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c2fc42882b8bc3efc7f6bb231a983b54fb1a3bb4;p=ceph-ci.git crimson/osd: add crush_location_hook feature to crimson Signed-off-by: luo rixin (cherry picked from commit 34671cc66dda67a7349cb2ca86f049d7a5969fd1) --- diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index e543b38e613..735b6d777ca 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -55,6 +55,7 @@ #include "crimson/osd/osd_operations/recovery_subrequest.h" #include "crimson/osd/osd_operations/replicated_request.h" #include "crimson/osd/osd_operation_external_tracking.h" +#include "crimson/crush/CrushLocation.h" namespace { seastar::logger& logger() { @@ -556,15 +557,21 @@ seastar::future<> OSD::_add_me_to_crush() } }; return get_weight().then([this](auto weight) { - const crimson::crush::CrushLocation loc{make_unique().get()}; - logger().info("{} crush location is {}", __func__, loc); - string cmd = fmt::format(R"({{ - "prefix": "osd crush create-or-move", - "id": {}, - "weight": {:.4f}, - "args": [{}] - }})", whoami, weight, loc); - return monc->run_command(std::move(cmd), {}); + const crimson::crush::CrushLocation loc; + return seastar::do_with( + std::move(loc), + [this, weight] (crimson::crush::CrushLocation& loc) { + return loc.init_on_startup().then([this, weight, &loc]() { + logger().info("crush location is {}", loc); + string cmd = fmt::format(R"({{ + "prefix": "osd crush create-or-move", + "id": {}, + "weight": {:.4f}, + "args": [{}] + }})", whoami, weight, loc); + return monc->run_command(std::move(cmd), {}); + }); + }); }).then([](auto&& command_result) { [[maybe_unused]] auto [code, message, out] = std::move(command_result); if (code) {