]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: do not hardwire crushtool command line
authorLoic Dachary <ldachary@redhat.com>
Mon, 2 Mar 2015 10:14:18 +0000 (11:14 +0100)
committerLoic Dachary <ldachary@redhat.com>
Tue, 3 Mar 2015 01:13:08 +0000 (02:13 +0100)
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 <loic@dachary.org>
src/common/config_opts.h
src/crush/CrushTester.cc
src/crush/CrushTester.h
src/mon/Monitor.cc
src/mon/OSDMonitor.cc

index 6f3fca80ffc62e939dd040c4add9675b4e966712..b13eb0982606c9b537ace1fd64a2be1338fa3fcd 100644 (file)
@@ -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)
index 10ea397469fcf7b94405d646c20e9b995f4c8e13..69dd5f8461391b7de982251540c65143a7d26b36 100644 (file)
@@ -355,10 +355,10 @@ void CrushTester::write_integer_indexed_scalar_data_string(vector<string> &dst,
   dst.push_back( data_buffer.str() );
 }
 
-int CrushTester::test_with_crushtool()
+int CrushTester::test_with_crushtool(const string& crushtool)
 {
   vector<const char *> 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;
   }
 
index 8fdb1aa4308ffd807a510b9c19a8365cf2186ff3..740205946e57df762348b2d258105b6a0b810bb7 100644 (file)
@@ -334,7 +334,7 @@ public:
   }
 
   int test();
-  int test_with_crushtool();
+  int test_with_crushtool(const string& crushtool);
 };
 
 #endif
index aafc56c29008e759baa5ad3580d8e81c28acc93f..9e1a6ac379640bfa7779d363afd89e0ee3ff3292 100644 (file)
@@ -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",
index 71bea3f3976ff89a831cdd0e227be464bd597de2..77dd265e9ff1cf109e8a4ffe9255bfd2fc00b630 100644 (file)
@@ -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();