From: Kefu Chai Date: Sat, 29 May 2021 06:48:11 +0000 (+0800) Subject: crimson/osd/main: handle and rethrow exception in fetch_config() X-Git-Tag: v17.1.0~1802^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6eba570dbce495bbcac06d4525e0da456dfe69c2;p=ceph.git crimson/osd/main: handle and rethrow exception in fetch_config() print more verbose error message when monc fails to connect to moitor. for better user experience. also, unregister all dispatchers by calling msgr->stop() before calling monc.stop() to ensure the messenger can be shutdown gracefully. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/osd/main.cc b/src/crimson/osd/main.cc index c228144e82db..5fbfc1e4b21e 100644 --- a/src/crimson/osd/main.cc +++ b/src/crimson/osd/main.cc @@ -153,11 +153,17 @@ seastar::future<> fetch_config() msgr->set_auth_client(&monc); msgr->start({&monc}).get(); auto stop_msgr = seastar::defer([&] { + // stop msgr here also, in case monc fails to start. msgr->stop(); msgr->shutdown().get(); }); - monc.start().get(); + monc.start().handle_exception([] (auto ep) { + seastar::fprint(std::cerr, "FATAL: unable to connect to cluster: {}\n", ep); + return seastar::make_exception_future<>(ep); + }).get(); auto stop_monc = seastar::defer([&] { + // unregister me from msgr first. + msgr->stop(); monc.stop().get(); }); monc.sub_want("config", 0, 0);