From: Kefu Chai Date: Thu, 21 Jan 2021 12:46:47 +0000 (+0800) Subject: crimson/osd: fetch_config() before mkfs X-Git-Tag: v17.0.0~4^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=84b2e0679400235fe3cedb039e71a6b46e34d9f0;p=ceph.git crimson/osd: fetch_config() before mkfs * 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 --- diff --git a/src/crimson/osd/main.cc b/src/crimson/osd/main.cc index a90903e7227..edc712b2b21 100644 --- a/src/crimson/osd/main.cc +++ b/src/crimson/osd/main.cc @@ -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(); + auto msgr = crimson::net::Messenger::create(entity_name_t::CLIENT(), + "temp_mon_client", + get_nonce()); + auto monc = std::make_unique(*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,