]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/ceph_monstore_tool: rebuild initial mgrmap also 19240/head
authorKefu Chai <kchai@redhat.com>
Wed, 29 Nov 2017 12:21:33 +0000 (20:21 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 29 Nov 2017 15:50:07 +0000 (23:50 +0800)
Fixes: http://tracker.ceph.com/issues/22266
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit f63d1da4afa3463730ecbc0be29df6375b79fa8f)

src/tools/CMakeLists.txt
src/tools/ceph_monstore_tool.cc

index ed19c63bc3c7da87dfb9ee6fa043d95683f1dc0b..7502085895afe77af48cfd55f1ddbf89c3c48353 100644 (file)
@@ -26,7 +26,9 @@ add_executable(ceph-osdomap-tool ceph_osdomap_tool.cc)
 target_link_libraries(ceph-osdomap-tool os global Boost::program_options)
 install(TARGETS ceph-osdomap-tool DESTINATION bin)
 
-add_executable(ceph-monstore-tool ceph_monstore_tool.cc)
+add_executable(ceph-monstore-tool
+  ceph_monstore_tool.cc
+  ../mgr/mgr_commands.cc)
 target_link_libraries(ceph-monstore-tool os global Boost::program_options)
 install(TARGETS ceph-monstore-tool DESTINATION bin)
 install(PROGRAMS
index 8c941443d818ffe65ea787bf70825cd0df241fb3..bf607ffa9c415f44151874c6e88f99689f533f77 100644 (file)
@@ -24,6 +24,7 @@
 #include "auth/cephx/CephxKeyServer.h"
 #include "global/global_init.h"
 #include "include/stringify.h"
+#include "mgr/mgr_commands.h"
 #include "mon/AuthMonitor.h"
 #include "mon/MonitorDBStore.h"
 #include "mon/Paxos.h"
@@ -588,6 +589,36 @@ static int update_monitor(MonitorDBStore& st)
   return 0;
 }
 
+static int update_mgrmap(MonitorDBStore& st)
+{
+  auto t = make_shared<MonitorDBStore::Transaction>();
+
+  {
+    MgrMap map;
+    // mgr expects epoch > 1
+    map.epoch++;
+    auto initial_modules =
+      get_str_vec(g_ceph_context->_conf->get_val<string>("mgr_initial_modules"));
+    copy(begin(initial_modules),
+        end(initial_modules),
+        inserter(map.modules, end(map.modules)));
+    bufferlist bl;
+    map.encode(bl, CEPH_FEATURES_ALL);
+    t->put("mgr", map.epoch, bl);
+    t->put("mgr", "last_committed", map.epoch);
+  }
+  {
+    auto mgr_command_descs = mgr_commands;
+    for (auto& c : mgr_command_descs) {
+      c.set_flag(MonCommand::FLAG_MGR);
+    }
+    bufferlist bl;
+    ::encode(mgr_command_descs, bl);
+    t->put("mgr_command_desc", "", bl);
+  }
+  return st.apply_transaction(t);
+}
+
 static int update_paxos(MonitorDBStore& st)
 {
   // build a pending paxos proposal from all non-permanent k/v pairs. once the
@@ -598,6 +629,7 @@ static int update_paxos(MonitorDBStore& st)
   {
     MonitorDBStore::Transaction t;
     vector<string> prefixes = {"auth", "osdmap",
+                              "mgr", "mgr_command_desc",
                               "pgmap", "pgmap_pg", "pgmap_meta"};
     for (const auto& prefix : prefixes) {
       for (auto i = st.get_iterator(prefix); i->valid(); i->next()) {
@@ -706,6 +738,9 @@ int rebuild_monstore(const char* progname,
   if ((r = update_monitor(st))) {
     return r;
   }
+  if ((r = update_mgrmap(st))) {
+    return r;
+  }
   return 0;
 }