From 6ca6c4bf94b13ea02badcc5d2ca71edc131987d9 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Fri, 19 Mar 2021 23:55:04 +0000 Subject: [PATCH] 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 --- src/mon/MonmapMonitor.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index 80ca4de24e6a8..f827a078a0439 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(); -- 2.39.5