From: Loic Dachary Date: Mon, 2 Mar 2015 10:14:18 +0000 (+0100) Subject: mon: do not hardwire crushtool command line X-Git-Tag: v0.94~63^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7a5a635ffb9241511f706b04de1a42b2eb7533c5;p=ceph.git mon: do not hardwire crushtool command line Make crushtool a configuration value that defaults to crushtool and allow it to be injected. It helps with testing: the command can be replaced with another that misbehaves in various ways. Signed-off-by: Loic Dachary --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 6f3fca80ffc6..b13eb0982606 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -251,6 +251,7 @@ OPTION(mon_osd_min_down_reporters, OPT_INT, 1) // number of OSDs who need to r OPTION(mon_osd_min_down_reports, OPT_INT, 3) // number of times a down OSD must be reported for it to count OPTION(mon_osd_force_trim_to, OPT_INT, 0) // force mon to trim maps to this point, regardless of min_last_epoch_clean (dangerous, use with care) OPTION(mon_mds_force_trim_to, OPT_INT, 0) // force mon to trim mdsmaps to this point (dangerous, use with care) +OPTION(crushtool, OPT_STR, "crushtool") // dump transactions OPTION(mon_debug_dump_transactions, OPT_BOOL, false) diff --git a/src/crush/CrushTester.cc b/src/crush/CrushTester.cc index 10ea397469fc..69dd5f846139 100644 --- a/src/crush/CrushTester.cc +++ b/src/crush/CrushTester.cc @@ -355,10 +355,10 @@ void CrushTester::write_integer_indexed_scalar_data_string(vector &dst, dst.push_back( data_buffer.str() ); } -int CrushTester::test_with_crushtool() +int CrushTester::test_with_crushtool(const string& crushtool) { vector cmd_args; - cmd_args.push_back("crushtool"); + cmd_args.push_back(crushtool.c_str()); cmd_args.push_back("-i"); cmd_args.push_back("-"); cmd_args.push_back("--test"); @@ -414,7 +414,7 @@ int CrushTester::test_with_crushtool() } if (r == ENOENT) { - err << "unable to find 'crushtool' to test the map"; + err << "unable to find " << cmd_args << " to test the map"; return -ENOENT; } diff --git a/src/crush/CrushTester.h b/src/crush/CrushTester.h index 8fdb1aa4308f..740205946e57 100644 --- a/src/crush/CrushTester.h +++ b/src/crush/CrushTester.h @@ -334,7 +334,7 @@ public: } int test(); - int test_with_crushtool(); + int test_with_crushtool(const string& crushtool); }; #endif diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index aafc56c29008..9e1a6ac37964 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -437,6 +437,7 @@ void Monitor::write_features(MonitorDBStore::TransactionRef t) const char** Monitor::get_tracked_conf_keys() const { static const char* KEYS[] = { + "crushtool", // helpful for testing "mon_lease", "mon_lease_renew_interval", "mon_lease_ack_timeout", diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 71bea3f3976f..77dd265e9ff1 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -4526,7 +4526,7 @@ bool OSDMonitor::prepare_command_impl(MMonCommand *m, dout(10) << " testing map" << dendl; stringstream ess; CrushTester tester(crush, ess); - int r = tester.test_with_crushtool(); + int r = tester.test_with_crushtool(g_conf->crushtool); if (r < 0) { derr << "error on crush map: " << ess.str() << dendl; ss << "Failed to parse crushmap: " << ess.str();