From: Greg Farnum Date: Fri, 19 Mar 2021 23:55:04 +0000 (+0000) Subject: mon: if in stretch mode, don't allow new mons to join without a location X-Git-Tag: v17.1.0~2419^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6ca6c4bf94b13ea02badcc5d2ca71edc131987d9;p=ceph-ci.git mon: if in stretch mode, don't allow new mons to join without a location 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 --- diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index 80ca4de24e6..f827a078a04 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -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();