]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-mon: set up auth before binding
authorSage Weil <sage@redhat.com>
Thu, 31 Jan 2019 15:28:30 +0000 (09:28 -0600)
committerSage Weil <sage@redhat.com>
Thu, 7 Feb 2019 18:10:34 +0000 (12:10 -0600)
Otherwise initial connections will fail because they lack the auth_server.

Signed-off-by: Sage Weil <sage@redhat.com>
src/ceph_mon.cc
src/mon/Monitor.cc

index 881499817d198f01ba125721c4fbc3497b874462..68828cdf650af18fe4de57a62c04b46232dcbc49 100644 (file)
@@ -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();
index 45c013daeb419ef99e7ce07c7d23392dc856840e..83e0205b87d85833223f5c8b84dd12b9d55d6ffc 100644 (file)
@@ -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