]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/main: handle and rethrow exception in fetch_config()
authorKefu Chai <kchai@redhat.com>
Sat, 29 May 2021 06:48:11 +0000 (14:48 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 29 May 2021 08:48:44 +0000 (16:48 +0800)
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 <kchai@redhat.com>
src/crimson/osd/main.cc

index c228144e82dba4b7e962b2a9ba422d2c36cde4d0..5fbfc1e4b21e0fda219c43ee4763f25784cd3fcc 100644 (file)
@@ -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);