]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon,cephfs: require confirmation when changing max_mds on unhealthy cluster
authorRishabh Dave <ridave@redhat.com>
Fri, 23 Aug 2024 12:49:43 +0000 (18:19 +0530)
committerRishabh Dave <ridave@redhat.com>
Mon, 15 Sep 2025 06:14:11 +0000 (11:44 +0530)
User must pass the confirmation flag (--yes-i-really-mean-it) to change
the value of CephFS setting variable "max_mds" when the Ceph cluster is
unhealthy.

This measure was decided upon to prevent users from changing "max_mds"
as a measure of troubleshotoing unhealthy cluster.

Fixes: https://tracker.ceph.com/issues/66301
Signed-off-by: Rishabh Dave <ridave@redhat.com>
(cherry picked from commit a55a75c57e7a42a1317e4d7fc86c1964b71137f0)

Conflicts:

src/mon/FSCommands.cc
- Method set_val() is present in this file on main branch but not on
  Reef branch

src/mon/FSCommands.cc
src/mon/MDSMonitor.cc
src/mon/MDSMonitor.h

index 419fcc67d8a6c9aff8c150102bb0b82e36cd5364..e465a4434f9bf395b3d79e134490c0553574e429 100644 (file)
@@ -349,12 +349,25 @@ public:
       ss << "Invalid variable";
       return -EINVAL;
     }
+
     string val;
-    string interr;
-    int64_t n = 0;
     if (!cmd_getval(cmdmap, "val", val)) {
       return -EINVAL;
     }
+
+    bool confirm = false;
+    cmd_getval(cmdmap, "yes_i_really_mean_it", confirm);
+    if (var == "max_mds" && !confirm && mon->mdsmon()->has_any_health_warning()) {
+      ss << "One or more file system health warnings are present. Modifying "
+        << "the file system setting variable \"max_mds\" may not help "
+        << "troubleshoot or recover from these warnings and may further "
+        << "destabilize the system. If you really wish to proceed, run "
+        << "again with --yes-i-really-mean-it";
+      return -EPERM;
+    }
+
+    string interr;
+    int64_t n = 0;
     // we got a string.  see if it contains an int.
     n = strict_strtoll(val.c_str(), 10, &interr);
     if (var == "max_mds") {
index 3c5dd085ec315bc3aaa37b5f012d7007272df348..e10be936e0a7f7c5a5f986c5ba5f282593058323 100644 (file)
@@ -1477,6 +1477,13 @@ bool MDSMonitor::has_health_warnings(vector<mds_metric_t> warnings)
   return false;
 }
 
+bool MDSMonitor::has_any_health_warning()
+{
+  return std::any_of(
+    pending_daemon_health.begin(), pending_daemon_health.end(),
+    [](auto& it) { return !it.second.metrics.empty() ? true : false; });
+}
+
 int MDSMonitor::filesystem_command(
     FSMap &fsmap,
     MonOpRequestRef op,
index 0157a47177c0e62cf1acad5518fd6848416349c9..3ab53e2d9740bf882b6ed7974b3e702efa645083 100644 (file)
@@ -53,6 +53,7 @@ class MDSMonitor : public PaxosService, public PaxosFSMap, protected CommandHand
   bool prepare_update(MonOpRequestRef op) override;
   bool should_propose(double& delay) override;
   bool has_health_warnings(std::vector<mds_metric_t> warnings);
+  bool has_any_health_warning();
 
   bool should_print_status() const {
     auto& fs = get_fsmap();