]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: set our addr when populating monmap with initial members
authorSage Weil <sage@inktank.com>
Fri, 18 May 2012 00:51:47 +0000 (17:51 -0700)
committerSage Weil <sage@inktank.com>
Fri, 18 May 2012 23:23:58 +0000 (16:23 -0700)
If the seed monmap doesn't contain us and we are populating it with
initial members, and one of those members is us, use our addr instead of
using a dummy one.

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

index 6ac23f8f9fa9d24637208cc816df537f4016eb43..7a6cb1b267cfcfbf07f3df9c661fc78bec372091 100644 (file)
@@ -311,15 +311,20 @@ int Monitor::init()
       // add missing initial members
       for (list<string>::iterator p = initial_members.begin(); p != initial_members.end(); ++p) {
        if (!monmap->contains(*p)) {
-         entity_addr_t a;
-         a.set_family(AF_INET);
-         for (int n=1; ; n++) {
-           a.set_port(n);
-           if (!monmap->contains(a))
-             break;
+         if (*p == name) {
+           dout(1) << " adding self " << *p << " " << messenger->get_myaddr() << dendl;
+           monmap->add(*p, messenger->get_myaddr());
+         } else {
+           entity_addr_t a;
+           a.set_family(AF_INET);
+           for (int n=1; ; n++) {
+             a.set_port(n);
+             if (!monmap->contains(a))
+               break;
+           }
+           dout(1) << " adding " << *p << " " << a << dendl;
+           monmap->add(*p, a);
          }
-         dout(1) << " adding " << *p << " " << a << dendl;
-         monmap->add(*p, a);
          assert(monmap->contains(*p));
        }
       }