From f4d50c8f1461ddd0104e41c53e447ff5adbf722f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 18 Jul 2017 15:49:31 -0400 Subject: [PATCH] mon: define static mgr_commands at mkfs time This closes a window between mkfs and when the first mgr goes active where *no* mgr commands are defined, and things like 'pg dump' fail. We do not get the default set of commands defined by modules, but we get everything else. Signed-off-by: Sage Weil --- src/mon/CMakeLists.txt | 3 ++- src/mon/MgrMonitor.cc | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/mon/CMakeLists.txt b/src/mon/CMakeLists.txt index 556157132f8..04044543c21 100644 --- a/src/mon/CMakeLists.txt +++ b/src/mon/CMakeLists.txt @@ -20,7 +20,8 @@ set(lib_mon_srcs DataHealthService.cc PGMonitor.cc PGMap.cc - ConfigKeyService.cc) + ConfigKeyService.cc + ../mgr/mgr_commands.cc) add_library(mon STATIC ${lib_mon_srcs} $ diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index bf70f7aee72..b858c5c0459 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -20,6 +20,7 @@ #include "PGStatService.h" #include "include/stringify.h" #include "mgr/MgrContext.h" +#include "mgr/mgr_commands.h" #include "OSDMonitor.h" #include "MgrMonitor.h" @@ -45,7 +46,10 @@ void MgrMonitor::create_initial() for (auto& m : tok) { pending_map.modules.insert(m); } - dout(10) << __func__ << " initial modules " << pending_map.modules << dendl; + pending_command_descs = mgr_commands; + dout(10) << __func__ << " initial modules " << pending_map.modules + << ", " << pending_command_descs.size() << " commands" + << dendl; } void MgrMonitor::update_from_paxos(bool *need_bootstrap) @@ -79,10 +83,11 @@ void MgrMonitor::update_from_paxos(bool *need_bootstrap) check_subs(); - if (map.get_available() - && (!old_available || old_gid != map.get_active_gid())) - { - dout(4) << "daemon transitioned to available, loading commands" << dendl; + if (version == 1 + || (map.get_available() + && (!old_available || old_gid != map.get_active_gid()))) { + dout(4) << "mkfs or daemon transitioned to available, loading commands" + << dendl; bufferlist loaded_commands; int r = mon->store->get(command_descs_prefix, "", loaded_commands); if (r < 0) { -- 2.39.5