Skip to content

Commit

Permalink
tools/ceph_monstore_tool: rebuild initial mgrmap also
Browse files Browse the repository at this point in the history
  • Loading branch information
tchaikov committed Nov 29, 2017
1 parent 993b5f3 commit f63d1da
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions src/tools/ceph_monstore_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -591,6 +592,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
Expand All @@ -601,6 +632,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()) {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit f63d1da

Please sign in to comment.