]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: make bootstrap rank check more robust
authorSage Weil <sage@redhat.com>
Tue, 15 Jan 2019 16:42:18 +0000 (10:42 -0600)
committerSage Weil <sage@redhat.com>
Tue, 15 Jan 2019 16:54:56 +0000 (10:54 -0600)
If we search for myaddrs, then we will detect our rank properly if we were
[a,b] and the a addr got removed.

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

index 5a852807ddb77dca9cb5fcb03e5fe1ae0909084b..f5a230c712975661bc6632b57b5f57fd6b9feac7 100644 (file)
@@ -327,10 +327,17 @@ public:
   }
   int get_rank(const entity_addr_t& a) const {
     string n = get_name(a);
-    if (n.empty())
-      return -1;
-
-    return get_rank(n);
+    if (!n.empty()) {
+      return get_rank(n);
+    }
+    return -1;
+  }
+  int get_rank(const entity_addrvec_t& av) const {
+    string n = get_name(av);
+    if (!n.empty()) {
+      return get_rank(n);
+    }
+    return -1;
   }
   bool get_addr_name(const entity_addr_t& a, string& name) {
     if (addr_mons.count(a) == 0)
index 793e037bc3dfef618ae6b190fbd9e166e60fff96..71a0b0e5b10787f009d875b3faf7e8ec329d9ff3 100644 (file)
@@ -1086,7 +1086,7 @@ void Monitor::bootstrap()
   dout(10) << "monmap " << *monmap << dendl;
 
   // note my rank
-  int newrank = monmap->get_rank(messenger->get_myaddr());
+  int newrank = monmap->get_rank(messenger->get_myaddrs());
   if (newrank < 0 && rank >= 0) {
     // was i ever part of the quorum?
     if (has_ever_joined) {