Kill old mgr_modules option.
Add new mgr_initial_modules option, on the mon, for the initial cluster
mgrmap.
Add ls, enable, disable commands.
Respawn mgr if the module list changes. In the future we could enable
new modules without a full restart, but disabling probably requires (and
is best handled by) a respawn.
Signed-off-by: Sage Weil <sage@redhat.com>
ceph_watch_wait "$mymsg"
ceph mgr dump
+ ceph mgr module ls
+ ceph mgr module enable foo
+ ceph mgr module disable foo
ceph mon metadata a
ceph mon metadata
OPTION(rgw_swift_versioning_enabled, OPT_BOOL, false) // whether swift object versioning feature is enabled
OPTION(mgr_module_path, OPT_STR, CEPH_PKGLIBDIR "/mgr") // where to load python modules from
-OPTION(mgr_modules, OPT_STR, "restful status") // Which modules to load
+OPTION(mgr_initial_modules, OPT_STR, "restful status") // Which modules to load
OPTION(mgr_data, OPT_STR, "/var/lib/ceph/mgr/$cluster-$id") // where to find keyring etc
OPTION(mgr_tick_period, OPT_INT, 2) // How frequently to tick
OPTION(mgr_stats_period, OPT_INT, 5) // How frequently clients send stats
daemon_state.cull(CEPH_ENTITY_TYPE_MDS, names_exist);
}
-void Mgr::got_mgr_map(const MgrMap& m)
+bool Mgr::got_mgr_map(const MgrMap& m)
{
Mutex::Locker l(lock);
dout(10) << m << dendl;
+
+ set<string> old_modules;
+ cluster_state.with_mgrmap([&](const MgrMap& m) {
+ old_modules = m.modules;
+ });
+ if (m.modules != old_modules) {
+ derr << "mgrmap module list changed to (" << m.modules << "), respawn"
+ << dendl;
+ return true;
+ }
cluster_state.set_mgr_map(m);
+ return false;
}
void Mgr::handle_mgr_digest(MMgrDigest* m)
void handle_osd_map();
void handle_log(MLog *m);
- void got_mgr_map(const MgrMap& m);
+ bool got_mgr_map(const MgrMap& m);
bool ms_dispatch(Message *m);
dout(1) << "I am now active" << dendl;
} else {
dout(10) << "I was already active" << dendl;
- active_mgr->got_mgr_map(map);
+ bool need_respawn = active_mgr->got_mgr_map(map);
+ if (need_respawn) {
+ respawn();
+ }
}
} else {
if (active_mgr != nullptr) {
#include "PyState.h"
#include "Gil.h"
-#include <boost/tokenizer.hpp>
#include "common/errno.h"
#include "include/stringify.h"
std::list<std::string> failed_modules;
// Load python code
- boost::tokenizer<> tok(g_conf->mgr_modules);
- for(const auto& module_name : tok) {
+ set<string> ls;
+ cluster_state.with_mgrmap([&](const MgrMap& m) {
+ ls = m.modules;
+ });
+ for (const auto& module_name : ls) {
dout(1) << "Loading python module '" << module_name << "'" << dendl;
auto mod = std::unique_ptr<MgrPyModule>(new MgrPyModule(module_name, sys_path, pMainThreadState));
int r = mod->load();
std::map<uint64_t, StandbyInfo> standbys;
+ std::set<std::string> modules;
+
epoch_t get_epoch() const { return epoch; }
entity_addr_t get_active_addr() const { return active_addr; }
uint64_t get_active_gid() const { return active_gid; }
void encode(bufferlist& bl, uint64_t features) const
{
- ENCODE_START(1, 1, bl);
+ ENCODE_START(2, 1, bl);
::encode(epoch, bl);
::encode(active_addr, bl, features);
::encode(active_gid, bl);
::encode(available, bl);
::encode(active_name, bl);
::encode(standbys, bl);
+ ::encode(modules, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& p)
{
- DECODE_START(1, p);
+ DECODE_START(2, p);
::decode(epoch, p);
::decode(active_addr, p);
::decode(active_gid, p);
::decode(available, p);
::decode(active_name, p);
::decode(standbys, p);
+ if (struct_v >= 2) {
+ ::decode(modules, p);
+ }
DECODE_FINISH(p);
}
f->close_section();
}
f->close_section();
+ f->open_array_section("modules");
+ for (auto& i : modules) {
+ f->dump_string("module", i);
+ }
+ f->close_section();
}
static void generate_test_instances(list<MgrMap*> &l) {
* Foundation. See file COPYING.
*/
+#include <boost/tokenizer.hpp>
+
#include "messages/MMgrBeacon.h"
#include "messages/MMgrMap.h"
#include "messages/MMgrDigest.h"
void MgrMonitor::create_initial()
{
+ boost::tokenizer<> tok(g_conf->mgr_initial_modules);
+ for (auto& m : tok) {
+ pending_map.modules.insert(m);
+ }
+ dout(10) << __func__ << " initial modules " << pending_map.modules << dendl;
}
void MgrMonitor::update_from_paxos(bool *need_bootstrap)
f->dump_object("mgrmap", m);
}
f->flush(rdata);
+ } else if (prefix == "mgr module ls") {
+ f->open_array_section("modules");
+ for (auto& p : map.modules) {
+ f->dump_string("module", p);
+ }
+ f->close_section();
+ f->flush(rdata);
} else {
return false;
}
return true;
}
+ string format;
+ cmd_getval(g_ceph_context, cmdmap, "format", format, string("plain"));
+ boost::scoped_ptr<Formatter> f(Formatter::create(format));
+
string prefix;
cmd_getval(g_ceph_context, cmdmap, "prefix", prefix);
if (changed && pending_map.active_gid == 0) {
promote_standby();
}
+ } else if (prefix == "mgr module enable") {
+ string module;
+ cmd_getval(g_ceph_context, cmdmap, "module", module);
+ if (module.empty()) {
+ r = -EINVAL;
+ goto out;
+ }
+ pending_map.modules.insert(module);
+ } else if (prefix == "mgr module disable") {
+ string module;
+ cmd_getval(g_ceph_context, cmdmap, "module", module);
+ if (module.empty()) {
+ r = -EINVAL;
+ goto out;
+ }
+ pending_map.modules.erase(module);
} else {
r = -ENOSYS;
}
+out:
dout(4) << __func__ << " done, r=" << r << dendl;
/* Compose response */
string rs;
"mgr", "r", "cli,rest")
COMMAND("mgr fail name=who,type=CephString", \
"treat the named manager daemon as failed", "mgr", "rw", "cli,rest")
+COMMAND("mgr module ls",
+ "list active mgr modules", "mgr", "r", "cli,rest")
+COMMAND("mgr module enable " \
+ "name=module,type=CephString",
+ "enable mgr module", "mgr", "rw", "cli,rest")
+COMMAND("mgr module disable " \
+ "name=module,type=CephString",
+ "enable mgr module", "mgr", "rw", "cli,rest")
FSID=$(uuidgen)
export CEPH_ARGS
CEPH_ARGS+="--fsid=$FSID --auth-supported=none "
- CEPH_ARGS+="--mon-initial-members=a --mon-host=$MON"
+ CEPH_ARGS+="--mon-initial-members=a --mon-host=$MON "
+ CEPH_ARGS+="--mgr-initial-modules=dashbaord "
+ CEPH_ARGS+="--mon-host=$MON"
run_mon $dir a --public-addr $MON || return 1
)
export CEPH_ARGS="--mon_host $MON "
ceph config-key put mgr/x/dashboard/server_port 7001
MGR_ARGS+="--mgr_module_path=${CEPH_ROOT}/src/pybind/mgr "
- MGR_ARGS+="--mgr_modules=dashboard "
run_mgr $dir x ${MGR_ARGS} || return 1
tries=0
mds root ino gid = `id -g`
$extra_conf
[mgr]
- mgr modules = restful status dashboard
mgr data = $CEPH_DEV_DIR/mgr.\$id
mgr module path = $MGR_PYTHON_PATH
mon reweight min pgs per osd = 4
$COSDSHORT
$extra_conf
[mon]
+ mgr initial modules = restful status dashboard
mon pg warn min per osd = 3
mon osd allow primary affinity = true
mon reweight min pgs per osd = 4