]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add "--check" to CrushTester::test_with_crushtool() 4726/head
authorKefu Chai <kchai@redhat.com>
Tue, 26 May 2015 10:11:59 +0000 (18:11 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 31 May 2015 17:24:54 +0000 (01:24 +0800)
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>
src/crush/CrushTester.cc
src/crush/CrushTester.h
src/mon/OSDMonitor.cc

index 47d094ad860728f4731aeb764f688be303b5bc2a..2a3ae8f47b456b61ca2d67fc20f6736593eb4f23 100644 (file)
@@ -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();
index 4522fdfdca9daa6c94d011434a15754dbbd94cb9..ed14761462ac903df133e13f76b80d4d60091c62 100644 (file)
@@ -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);
 };
 
index c60b273f233deae779b3f4d55b35f18db83905d5..dacd4b66859172a32b5c0fa6d23a763d468611f5 100644 (file)
@@ -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;