From: Sage Weil Date: Thu, 20 Jul 2017 19:59:38 +0000 (-0400) Subject: mon/MgrMonitor: store mgr daemon metadata X-Git-Tag: v12.1.2~164^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1bf4a89890d2312964f44b9b03640120a5a0cab2;p=ceph.git mon/MgrMonitor: store mgr daemon metadata Signed-off-by: Sage Weil --- diff --git a/src/messages/MMgrBeacon.h b/src/messages/MMgrBeacon.h index c2ccee1fc4d..2dd586df989 100644 --- a/src/messages/MMgrBeacon.h +++ b/src/messages/MMgrBeacon.h @@ -23,7 +23,7 @@ class MMgrBeacon : public PaxosServiceMessage { - static const int HEAD_VERSION = 4; + static const int HEAD_VERSION = 5; static const int COMPAT_VERSION = 1; protected: @@ -33,6 +33,7 @@ protected: std::string name; uuid_d fsid; std::set available_modules; + map metadata; ///< misc metadata about this osd // Only populated during activation std::vector command_descs; @@ -46,10 +47,11 @@ public: MMgrBeacon(const uuid_d& fsid_, uint64_t gid_, const std::string &name_, entity_addr_t server_addr_, bool available_, - const std::set& module_list) + const std::set& module_list, + const map& 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) { } @@ -59,6 +61,9 @@ public: const std::string& get_name() const { return name; } const uuid_d& get_fsid() const { return fsid; } std::set& get_available_modules() { return available_modules; } + const std::map& get_metadata() const { + return metadata; + } void set_command_descs(const std::vector &cmds) { @@ -92,6 +97,7 @@ public: ::encode(fsid, payload); ::encode(available_modules, payload); ::encode(command_descs, payload); + ::encode(metadata, payload); } void decode_payload() override { bufferlist::iterator p = payload.begin(); @@ -109,6 +115,9 @@ public: if (header.version >= 4) { ::decode(command_descs, p); } + if (header.version >= 5) { + ::decode(metadata, p); + } } }; diff --git a/src/mgr/MgrStandby.cc b/src/mgr/MgrStandby.cc index 6f83fc13f32..29e8b06af85 100644 --- a/src/mgr/MgrStandby.cc +++ b/src/mgr/MgrStandby.cc @@ -161,12 +161,16 @@ void MgrStandby::send_beacon() dout(10) << "sending beacon as gid " << monc.get_global_id() << " modules " << modules << dendl; + map 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 diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index b858c5c0459..3a18d681991 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -25,6 +25,8 @@ #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) @@ -35,7 +37,6 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon, << ").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"; @@ -138,6 +139,17 @@ void MgrMonitor::encode_pending(MonitorDBStore::TransactionRef t) 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(); @@ -329,6 +341,8 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op) 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; @@ -353,6 +367,8 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op) << " 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; } } @@ -592,6 +608,8 @@ void MgrMonitor::drop_active() 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; @@ -604,11 +622,12 @@ void MgrMonitor::drop_active() 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) diff --git a/src/mon/MgrMonitor.h b/src/mon/MgrMonitor.h index ed3e23e236b..639d31163aa 100644 --- a/src/mon/MgrMonitor.h +++ b/src/mon/MgrMonitor.h @@ -14,6 +14,9 @@ #ifndef CEPH_MGRMONITOR_H #define CEPH_MGRMONITOR_H +#include +#include + #include "include/Context.h" #include "MgrMap.h" #include "PaxosService.h" @@ -25,6 +28,9 @@ class MgrMonitor: public PaxosService MgrMap pending_map; bool ever_had_active_mgr = false; + std::map pending_metadata; + std::set pending_metadata_rm; + utime_t first_seen_inactive; std::map last_beacon;