]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: learn peer addrs when probing
authorSage Weil <sage@inktank.com>
Fri, 18 May 2012 00:52:54 +0000 (17:52 -0700)
committerSage Weil <sage@inktank.com>
Fri, 18 May 2012 23:23:58 +0000 (16:23 -0700)
If we have a monmap with dummy addrs for initial members, and we probe one
of those peers and learn their address, update our monmap appropriately.

Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/MonMap.h
src/mon/Monitor.cc

index 7daf8e79e62c3a8bcb7bab06196cd643b3a9c75f..e7982f137651bdcbbf333fc1eee5520bdc9e4acc 100644 (file)
@@ -162,6 +162,11 @@ class MonMap {
     assert(m < rank_addr.size());
     return rank_addr[m];
   }
+  void set_addr(const string& n, entity_addr_t a) {
+    assert(mon_addr.count(n));
+    mon_addr[n] = a;
+    calc_ranks();
+  }
   entity_inst_t get_inst(const string& n) {
     assert(mon_addr.count(n));
     int m = get_rank(n);
index 7a6cb1b267cfcfbf07f3df9c661fc78bec372091..e64739b2c4bd3d84109629785e3fa1e74b27e573 100644 (file)
@@ -703,6 +703,23 @@ void Monitor::handle_probe_reply(MMonProbe *m)
     monmap->rename(peer_name, m->name);
   }
 
+  // new initial peer?
+  if (monmap->contains(m->name)) {
+    entity_addr_t a = monmap->get_addr(m->name);
+    a.set_port(0);
+    entity_addr_t b;
+    b.set_family(AF_INET);
+    dout(1) << " a " << a <<" b " << b << dendl;
+    if (a == b) {
+      dout(1) << " learned initial mon " << m->name << " addr " << m->get_source_addr() << dendl;
+      monmap->set_addr(m->name, m->get_source_addr());
+      m->put();
+
+      bootstrap();
+      return;
+    }
+  }
+
   // is there an existing quorum?
   if (m->quorum.size()) {
     dout(10) << " existing quorum " << m->quorum << dendl;