]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
monmap: avoid dup addrs in generated initial monmap
authorSage Weil <sage@newdream.net>
Wed, 23 May 2012 17:39:48 +0000 (10:39 -0700)
committerSage Weil <sage@newdream.net>
Wed, 23 May 2012 17:39:48 +0000 (10:39 -0700)
We were getting a dup addr from -m <foo> and ceph.conf.  Prefer the
ceph.conf name in this case.

Also check for dup names here just to be thorough (even though I don't
think that can come up currently).

Fixes: #2464
Signed-off-by: Sage Weil <sage@newdream.net>
src/mon/MonMap.cc

index 22effb5f4b5756be3526ed99ab8675b079c19084..4a112a5557acafa325f69b57e6813edf616267a5 100644 (file)
@@ -305,7 +305,14 @@ int MonMap::build_initial(CephContext *cct, ostream& errout)
       continue;
     }
     if (addr.get_port() == 0)
-      addr.set_port(CEPH_MON_PORT);    
+      addr.set_port(CEPH_MON_PORT);
+
+    // the make sure this mon isn't already in the map
+    if (contains(addr))
+      remove(get_name(addr));
+    if (contains(*m))
+      remove(*m);
+
     add(m->c_str(), addr);
   }