]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: add crush_location_hook feature to crimson
authorluo rixin <luorixin@huawei.com>
Wed, 26 Apr 2023 09:07:55 +0000 (17:07 +0800)
committerluo rixin <luorixin@huawei.com>
Tue, 30 May 2023 02:14:21 +0000 (10:14 +0800)
Signed-off-by: luo rixin <luorixin@huawei.com>
(cherry picked from commit 34671cc66dda67a7349cb2ca86f049d7a5969fd1)

src/crimson/osd/osd.cc

index e543b38e613309482e1f330d990d1d64660264b0..735b6d777ca913ef0c2334a9ea8e4df6d17c61a0 100644 (file)
@@ -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<CephContext>().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) {