]> 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>
Tue, 17 Jun 2025 07:48:34 +0000 (13:18 +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() in present in this file in main branch but it's
  absent in Squid branch.

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

index e9774230997b530f60ee55d86ee8b50f57c9a366..63abe2973e5e22b1c3401464a605f95f6c63a588 100644 (file)
@@ -336,12 +336,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 76a57ac443de76ac29d3b49db544f9c36efe3bda..d8cca4ceb61b1f208c820b10cc9ee4593fc48bde 100644 (file)
@@ -1557,6 +1557,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 b0f88cd31302d779dace82506cc3c2edc1b46730..dd2a269009de2ad07f58f45f253741eda50cc1b0 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();