diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 490caca3f6814..e7bb5ae8ffb2b 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -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 diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc index 58a8cf386a054..8865cba378dd1 100644 --- a/src/tools/ceph_monstore_tool.cc +++ b/src/tools/ceph_monstore_tool.cc @@ -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" @@ -591,6 +592,36 @@ static int update_monitor(MonitorDBStore& st) return 0; } +static int update_mgrmap(MonitorDBStore& st) +{ + auto t = make_shared(); + + { + MgrMap map; + // mgr expects epoch > 1 + map.epoch++; + auto initial_modules = + get_str_vec(g_ceph_context->_conf->get_val("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 @@ -601,6 +632,7 @@ static int update_paxos(MonitorDBStore& st) { MonitorDBStore::Transaction t; vector 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()) { @@ -709,6 +741,9 @@ int rebuild_monstore(const char* progname, if ((r = update_monitor(st))) { return r; } + if ((r = update_mgrmap(st))) { + return r; + } return 0; }