class MMgrBeacon : public PaxosServiceMessage {
- static const int HEAD_VERSION = 4;
+ static const int HEAD_VERSION = 5;
static const int COMPAT_VERSION = 1;
protected:
std::string name;
uuid_d fsid;
std::set<std::string> available_modules;
+ map<string,string> metadata; ///< misc metadata about this osd
// Only populated during activation
std::vector<MonCommand> command_descs;
MMgrBeacon(const uuid_d& fsid_, uint64_t gid_, const std::string &name_,
entity_addr_t server_addr_, bool available_,
- const std::set<std::string>& module_list)
+ const std::set<std::string>& module_list,
+ const map<string,string>& metadata)
: PaxosServiceMessage(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION),
gid(gid_), server_addr(server_addr_), available(available_), name(name_),
- fsid(fsid_), available_modules(module_list)
+ fsid(fsid_), available_modules(module_list), metadata(metadata)
{
}
const std::string& get_name() const { return name; }
const uuid_d& get_fsid() const { return fsid; }
std::set<std::string>& get_available_modules() { return available_modules; }
+ const std::map<std::string,std::string>& get_metadata() const {
+ return metadata;
+ }
void set_command_descs(const std::vector<MonCommand> &cmds)
{
::encode(fsid, payload);
::encode(available_modules, payload);
::encode(command_descs, payload);
+ ::encode(metadata, payload);
}
void decode_payload() override {
bufferlist::iterator p = payload.begin();
if (header.version >= 4) {
::decode(command_descs, p);
}
+ if (header.version >= 5) {
+ ::decode(metadata, p);
+ }
}
};
dout(10) << "sending beacon as gid " << monc.get_global_id()
<< " modules " << modules << dendl;
+ map<string,string> metadata;
+ collect_sys_info(&metadata, g_ceph_context);
+
MMgrBeacon *m = new MMgrBeacon(monc.get_fsid(),
monc.get_global_id(),
g_conf->name.get_id(),
addr,
available,
- modules);
+ modules,
+ metadata);
if (available && !available_in_map) {
// We are informing the mon that we are done initializing: inform
#include "MgrMonitor.h"
+#define MGR_METADATA_PREFIX "mgr_metadata"
+
#define dout_subsys ceph_subsys_mon
#undef dout_prefix
#define dout_prefix _prefix(_dout, mon, map)
<< ").mgr e" << mgrmap.get_epoch() << " ";
}
-
// Prefix for mon store of active mgr's command descriptions
const static std::string command_descs_prefix = "mgr_command_descs";
put_version(t, pending_map.epoch, bl);
put_last_committed(t, pending_map.epoch);
+ for (auto& p : pending_metadata) {
+ dout(10) << __func__ << " set metadata for " << p.first << dendl;
+ t->put(MGR_METADATA_PREFIX, p.first, p.second);
+ }
+ for (auto& name : pending_metadata_rm) {
+ dout(10) << __func__ << " rm metadata for " << name << dendl;
+ t->erase(MGR_METADATA_PREFIX, name);
+ }
+ pending_metadata.clear();
+ pending_metadata_rm.clear();
+
health_check_map_t next;
if (pending_map.active_gid == 0) {
auto level = should_warn_about_mgr_down();
pending_map.active_gid = m->get_gid();
pending_map.active_name = m->get_name();
pending_map.available_modules = m->get_available_modules();
+ ::encode(m->get_metadata(), pending_metadata[m->get_name()]);
+ pending_metadata_rm.erase(m->get_name());
mon->clog->info() << "Activating manager daemon "
<< pending_map.active_name;
<< " started";
pending_map.standbys[m->get_gid()] = {m->get_gid(), m->get_name(),
m->get_available_modules()};
+ ::encode(m->get_metadata(), pending_metadata[m->get_name()]);
+ pending_metadata_rm.erase(m->get_name());
updated = true;
}
}
last_beacon.erase(pending_map.active_gid);
}
+ pending_metadata_rm.insert(pending_map.active_name);
+ pending_metadata.erase(pending_map.active_name);
pending_map.active_name = "";
pending_map.active_gid = 0;
pending_map.available = false;
void MgrMonitor::drop_standby(uint64_t gid)
{
+ pending_metadata_rm.insert(pending_map.standbys[gid].name);
+ pending_metadata.erase(pending_map.standbys[gid].name);
pending_map.standbys.erase(gid);
if (last_beacon.count(gid) > 0) {
last_beacon.erase(gid);
}
-
}
bool MgrMonitor::preprocess_command(MonOpRequestRef op)
#ifndef CEPH_MGRMONITOR_H
#define CEPH_MGRMONITOR_H
+#include <map>
+#include <set>
+
#include "include/Context.h"
#include "MgrMap.h"
#include "PaxosService.h"
MgrMap pending_map;
bool ever_had_active_mgr = false;
+ std::map<std::string, bufferlist> pending_metadata;
+ std::set<std::string> pending_metadata_rm;
+
utime_t first_seen_inactive;
std::map<uint64_t, ceph::coarse_mono_clock::time_point> last_beacon;