From: Sage Weil Date: Thu, 31 Jan 2019 15:28:30 +0000 (-0600) Subject: ceph-mon: set up auth before binding X-Git-Tag: v14.1.0~183^2~24 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=766df9f740b5d54eb33b8fef4bab397b4a889739;p=ceph.git ceph-mon: set up auth before binding Otherwise initial connections will fail because they lack the auth_server. Signed-off-by: Sage Weil --- diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index 881499817d19..68828cdf650a 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -772,18 +772,6 @@ int main(int argc, const char **argv) << " fsid " << monmap.get_fsid() << dendl; - err = msgr->bindv(bind_addrs); - if (err < 0) { - derr << "unable to bind monitor to " << bind_addrs << dendl; - prefork.exit(1); - } - - // if the public and bind addr are different set the msgr addr - // to the public one, now that the bind is complete. - if (public_addrs != bind_addrs) { - msgr->set_addrs(public_addrs); - } - Messenger *mgr_msgr = Messenger::create(g_ceph_context, public_msgr_type, entity_name_t::MON(rank), "mon-mgrc", getpid(), 0); @@ -792,13 +780,6 @@ int main(int argc, const char **argv) prefork.exit(1); } - dout(0) << "starting " << g_conf()->name << " rank " << rank - << " at " << public_addrs - << " mon_data " << g_conf()->mon_data - << " fsid " << monmap.get_fsid() - << dendl; - - // start monitor mon = new Monitor(g_ceph_context, g_conf()->name.get_id(), store, msgr, mgr_msgr, &monmap); @@ -825,6 +806,19 @@ int main(int argc, const char **argv) derr << "done compacting" << dendl; } + // bind + err = msgr->bindv(bind_addrs); + if (err < 0) { + derr << "unable to bind monitor to " << bind_addrs << dendl; + prefork.exit(1); + } + + // if the public and bind addr are different set the msgr addr + // to the public one, now that the bind is complete. + if (public_addrs != bind_addrs) { + msgr->set_addrs(public_addrs); + } + if (g_conf()->daemonize) { global_init_postfork_finish(g_ceph_context); prefork.daemonize(); diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 45c013daeb41..83e0205b87d8 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -856,6 +856,12 @@ int Monitor::preinit() // add ourselves as a conf observer g_conf().add_observer(this); + messenger->set_auth_client(this); + messenger->set_auth_server(this); + mgr_messenger->set_auth_client(this); + + auth_registry.refresh_config(); + lock.Unlock(); return 0; } @@ -875,15 +881,10 @@ int Monitor::init() // i'm ready! messenger->add_dispatcher_tail(this); - messenger->set_auth_client(this); - messenger->set_auth_server(this); mgr_client.init(); mgr_messenger->add_dispatcher_tail(&mgr_client); mgr_messenger->add_dispatcher_tail(this); // for auth ms_* calls - mgr_messenger->set_auth_client(this); - - auth_registry.refresh_config(); bootstrap(); // add features of myself into feature_map