mirror of
https://github.com/ceph/ceph
synced 2025-02-21 01:47:25 +00:00
mon: add "--check" to CrushTester::test_with_crushtool()
so we don't need to call CrushTester::check_name_maps() in OSDMonitor.cc anymore. Fixes: #11680 Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
parent
9381d53acd
commit
c6e6348753
@ -7,7 +7,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <common/SubProcess.h>
|
||||
|
||||
void CrushTester::set_device_weight(int dev, float f)
|
||||
@ -355,10 +355,11 @@ void CrushTester::write_integer_indexed_scalar_data_string(vector<string> &dst,
|
||||
dst.push_back( data_buffer.str() );
|
||||
}
|
||||
|
||||
int CrushTester::test_with_crushtool(const char *crushtool_cmd, int timeout)
|
||||
int CrushTester::test_with_crushtool(const char *crushtool_cmd, int max_id, int timeout)
|
||||
{
|
||||
SubProcessTimed crushtool(crushtool_cmd, true, false, true, timeout);
|
||||
crushtool.add_cmd_args("-i", "-", "--test", NULL);
|
||||
string opt_max_id = boost::lexical_cast<string>(max_id);
|
||||
crushtool.add_cmd_args("-i", "-", "--test", "--check", opt_max_id.c_str(), NULL);
|
||||
int ret = crushtool.spawn();
|
||||
if (ret != 0) {
|
||||
err << "failed run crushtool: " << crushtool.err();
|
||||
|
@ -343,6 +343,7 @@ public:
|
||||
bool check_name_maps(unsigned max_id = 0) const;
|
||||
int test();
|
||||
int test_with_crushtool(const char *crushtool_cmd = "crushtool",
|
||||
int max_id = -1,
|
||||
int timeout = 0);
|
||||
};
|
||||
|
||||
|
@ -4841,16 +4841,12 @@ bool OSDMonitor::prepare_command_impl(MMonCommand *m,
|
||||
dout(10) << " testing map" << dendl;
|
||||
stringstream ess;
|
||||
CrushTester tester(crush, ess);
|
||||
if (!tester.check_name_maps(osdmap.get_max_osd())) {
|
||||
err = -EINVAL;
|
||||
ss << ess.str();
|
||||
goto reply;
|
||||
}
|
||||
// XXX: Use mon_lease as a timeout value for crushtool.
|
||||
// If the crushtool consistently takes longer than 'mon_lease' seconds,
|
||||
// then we would consistently trigger an election before the command
|
||||
// finishes, having a flapping monitor unable to hold quorum.
|
||||
int r = tester.test_with_crushtool(g_conf->crushtool.c_str(),
|
||||
osdmap.get_max_osd(),
|
||||
g_conf->mon_lease);
|
||||
if (r < 0) {
|
||||
derr << "error on crush map: " << ess.str() << dendl;
|
||||
|
Loading…
Reference in New Issue
Block a user