]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: if in stretch mode, don't allow new mons to join without a location
authorGreg Farnum <gfarnum@redhat.com>
Fri, 19 Mar 2021 23:55:04 +0000 (23:55 +0000)
committerGreg Farnum <gfarnum@redhat.com>
Mon, 22 Mar 2021 21:40:26 +0000 (21:40 +0000)
We blocked off the other routes to add location-less monitors, but if you
turn on a monitor with the right keys it can auto-join via the MMonJoin
functionality. Block that off!

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/mon/MonmapMonitor.cc

index 80ca4de24e6a8fe5aae54ffab88b88475a3ef679..f827a078a043935bcd719732c8e18cdab2287a02 100644 (file)
@@ -1249,13 +1249,27 @@ bool MonmapMonitor::preprocess_join(MonOpRequestRef op)
     dout(10) << " already have " << join->name << dendl;
     return true;
   }
-  if (pending_map.contains(join->addrs) &&
-      pending_map.get_name(join->addrs) == join->name) {
+  string addr_name;
+  if (pending_map.contains(join->addrs)) {
+    addr_name = pending_map.get_name(join->addrs);
+  }
+  if (!addr_name.empty() &&
+      addr_name == join->name) {
     dout(10) << " already have " << join->addrs << dendl;
     return true;
   }
+  if (pending_map.stretch_mode_enabled &&
+      (addr_name.empty() ||
+       pending_map.mon_info[addr_name].crush_loc.empty())) {
+    dout(10) << "stretch mode engaged but no source of crush_loc" << dendl;
+    mon.clog->info() << join->name << " attempted to join from " << join->name
+                     << ' ' << join->addrs
+                     << "; but lacks a crush_location for stretch mode";
+    return true;
+  }
   return false;
 }
+
 bool MonmapMonitor::prepare_join(MonOpRequestRef op)
 {
   auto join = op->get_req<MMonJoin>();