From 6eba570dbce495bbcac06d4525e0da456dfe69c2 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 29 May 2021 14:48:11 +0800 Subject: [PATCH] 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 --- src/crimson/osd/main.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/crimson/osd/main.cc b/src/crimson/osd/main.cc index c228144e82d..5fbfc1e4b21 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); -- 2.39.5