From: Kamoltat Sirivadhna Date: Thu, 29 Aug 2024 18:23:43 +0000 (+0000) Subject: [Stretch Mode] mon: restrict changing mon election strategy post stretch mode X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7378581fd56b59d4864ef2844faabd5a32b656db;p=ceph.git [Stretch Mode] mon: restrict changing mon election strategy post stretch mode Problem: It is possible to modify the monitor election strategy once stretch mode is enabled. Solution: Restrict the ability for Ceph to change election strategy while using stretch mode. Also, notify the user if they attempt to change to the current election strategy. This change prevents unnecessary resource usage by informing the user when they try to switch to an election strategy that is already in use. This avoids redundant updates to the monmap. Fixes: https://tracker.ceph.com/issues/67801 Signed-off-by: Kamoltat Sirivadhna --- diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index 61942da6d8e4..b608a802b527 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -920,11 +920,32 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) err = -EINVAL; goto reply_no_propose; } + if (pending_map.stretch_mode_enabled) { + err = -EINVAL; + ss << "Stretch mode is enabled, so you cannot change the election strategy; please disable stretch mode first!"; + ceph_assert(pending_map.strategy == MonMap::CONNECTIVITY); + goto reply_no_propose; + } if (strat == "classic") { + if (pending_map.strategy == MonMap::CLASSIC) { + err = 0; + ss << "You are already in classic election strategy"; + goto reply_no_propose; + } strategy = MonMap::CLASSIC; } else if (strat == "disallow") { + if (pending_map.strategy == MonMap::DISALLOW) { + err = 0; + ss << "You are already in disallow election strategy"; + goto reply_no_propose; + } strategy = MonMap::DISALLOW; } else if (strat == "connectivity") { + if (pending_map.strategy == MonMap::CONNECTIVITY) { + err = 0; + ss << "You are already in connectivity election strategy"; + goto reply_no_propose; + } strategy = MonMap::CONNECTIVITY; } else { err = -EINVAL;