]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
[Stretch Mode] mon: restrict changing mon election strategy post stretch mode
authorKamoltat Sirivadhna <ksirivad@redhat.com>
Thu, 29 Aug 2024 18:23:43 +0000 (18:23 +0000)
committerKamoltat Sirivadhna <ksirivad@redhat.com>
Wed, 3 Sep 2025 17:18:47 +0000 (17:18 +0000)
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 <ksirivad@redhat.com>
src/mon/MonmapMonitor.cc

index 61942da6d8e4d3d345b4cc2b2493029bed0cf015..b608a802b52714872c03a1e116cada5f08d9d64b 100644 (file)
@@ -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;