]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.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>
Thu, 11 May 2023 00:48:06 +0000 (08:48 +0800)
Signed-off-by: luo rixin <luorixin@huawei.com>
src/crimson/osd/osd.cc

index 6ec72bf69337fa09af4ff0df33a5dff1c4a035d4..4cfc8740bb534d312860f7188e79fabe21de7c6b 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() {
@@ -557,15 +558,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) {