Skip to content

Commit a55a75c

Browse files
mon,cephfs: require confirmation when changing max_mds on unhealthy cluster
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 <[email protected]>
1 parent a61eabe commit a55a75c

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/mon/FSCommands.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,17 @@ class SetHandler : public FileSystemCommandHandler
385385
return -EINVAL;
386386
}
387387

388+
bool confirm = false;
389+
cmd_getval(cmdmap, "yes_i_really_mean_it", confirm);
390+
if (var == "max_mds" && !confirm && mon->mdsmon()->has_any_health_warning()) {
391+
ss << "One or more file system health warnings are present. Modifying "
392+
<< "the file system setting variable \"max_mds\" may not help "
393+
<< "troubleshoot or recover from these warnings and may further "
394+
<< "destabilize the system. If you really wish to proceed, run "
395+
<< "again with --yes-i-really-mean-it";
396+
return -EPERM;
397+
}
398+
388399
return set_val(mon, fsmap, op, cmdmap, ss, fsp->get_fscid(), var, val);
389400
}
390401
};

src/mon/MDSMonitor.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,13 @@ bool MDSMonitor::has_health_warnings(vector<mds_metric_t> warnings)
15571557
return false;
15581558
}
15591559

1560+
bool MDSMonitor::has_any_health_warning()
1561+
{
1562+
return std::any_of(
1563+
pending_daemon_health.begin(), pending_daemon_health.end(),
1564+
[](auto& it) { return !it.second.metrics.empty() ? true : false; });
1565+
}
1566+
15601567
int MDSMonitor::filesystem_command(
15611568
FSMap &fsmap,
15621569
MonOpRequestRef op,

src/mon/MDSMonitor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class MDSMonitor : public PaxosService, public PaxosFSMap, protected CommandHand
5353
bool prepare_update(MonOpRequestRef op) override;
5454
bool should_propose(double& delay) override;
5555
bool has_health_warnings(std::vector<mds_metric_t> warnings);
56+
bool has_any_health_warning();
5657

5758
bool should_print_status() const {
5859
auto& fs = get_fsmap();

0 commit comments

Comments
 (0)