]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: fetch_config() before mkfs
authorKefu Chai <kchai@redhat.com>
Thu, 21 Jan 2021 12:46:47 +0000 (20:46 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 22 Jan 2021 05:07:48 +0000 (13:07 +0800)
* fetch_config() before mkfs and starting osd
  for populating settings related to booting and transport layer
  before it starts.
* set fsid read from monitor before mkfs
  it's crucial to mkfs if osd is supposed to retrieve the fsid
  from monitor.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/main.cc

index a90903e72271ef19972e14d5e917854ba1b1feb4..edc712b2b21345846a04e3adca4628f6a3ff7daa 100644 (file)
@@ -16,6 +16,7 @@
 #include "common/ceph_argparse.h"
 #include "crimson/common/buffer_io.h"
 #include "crimson/common/config_proxy.h"
+#include "crimson/mon/MonClient.h"
 #include "crimson/net/Messenger.h"
 #include "global/pidfile.h"
 
@@ -117,6 +118,43 @@ uint64_t get_nonce()
   }
 }
 
+seastar::future<> fetch_config()
+{
+  // i don't have any client before joining the cluster, so no need to have
+  // a proper auth handler
+  class DummyAuthHandler : public crimson::common::AuthHandler {
+  public:
+    void handle_authentication(const EntityName& name,
+                               const AuthCapsInfo& caps)
+    {}
+  };
+  auto auth_handler = std::make_unique<DummyAuthHandler>();
+  auto msgr = crimson::net::Messenger::create(entity_name_t::CLIENT(),
+                                              "temp_mon_client",
+                                              get_nonce());
+  auto monc = std::make_unique<crimson::mon::Client>(*msgr, *auth_handler);
+  msgr->set_auth_client(monc.get());
+  return msgr->start({monc.get()}).then([monc=monc.get()] {
+    return monc->start();
+  }).then([monc=monc.get()] {
+    monc->sub_want("config", 0, 0);
+    return monc->renew_subs();
+  }).then([monc=monc.get()] {
+    // wait for monmap and config
+    return monc->wait_for_config();
+  }).then([monc=monc.get()] {
+    return local_conf().set_val("fsid", monc->get_fsid().to_string());
+  }).then([monc=monc.get(), msgr=msgr.get()] {
+    msgr->stop();
+    return monc->stop();
+  }).then([msgr=msgr.get()] {
+    return msgr->shutdown();
+  }).then([msgr=std::move(msgr),
+           auth_handler=std::move(auth_handler),
+           monc=std::move(monc)]
+  {});
+}
+
 int main(int argc, char* argv[])
 {
   seastar::app_template app;
@@ -198,6 +236,7 @@ int main(int argc, char* argv[])
             seastar::engine().exit(1);
           }).get();
         }
+        fetch_config().get();
         if (config.count("mkfs")) {
           osd.invoke_on(
            0,