]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MgrMonitor: store mgr daemon metadata
authorSage Weil <sage@redhat.com>
Thu, 20 Jul 2017 19:59:38 +0000 (15:59 -0400)
committerSage Weil <sage@redhat.com>
Fri, 21 Jul 2017 15:24:44 +0000 (11:24 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/messages/MMgrBeacon.h
src/mgr/MgrStandby.cc
src/mon/MgrMonitor.cc
src/mon/MgrMonitor.h

index c2ccee1fc4d314fd11ca2a5e686f6010f76511e1..2dd586df98916a95915366d66df6db74d8c36de6 100644 (file)
@@ -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<std::string> available_modules;
+  map<string,string> metadata; ///< misc metadata about this osd
 
   // Only populated during activation
   std::vector<MonCommand> 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<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)
   {
   }
 
@@ -59,6 +61,9 @@ public:
   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)
   {
@@ -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);
+    }
   }
 };
 
index 6f83fc13f3267106040d2e04290f822d81911ebf..29e8b06af8559e3c80fea14f5523acb8cdbfa0c8 100644 (file)
@@ -161,12 +161,16 @@ void MgrStandby::send_beacon()
   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
index b858c5c0459cc1786ad73bd1ae62a706591f39d4..3a18d6819912eada5f61843fc551ce9cc1120494 100644 (file)
@@ -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)
index ed3e23e236b3d5f7065d371c284072c9cb74ce6d..639d31163aaae1b3ff9f687aa39648e32762a2ae 100644 (file)
@@ -14,6 +14,9 @@
 #ifndef CEPH_MGRMONITOR_H
 #define CEPH_MGRMONITOR_H
 
+#include <map>
+#include <set>
+
 #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<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;