]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MgrMap: track active_changed timestamp
authorSage Weil <sage@redhat.com>
Mon, 6 Aug 2018 18:24:20 +0000 (13:24 -0500)
committerSage Weil <sage@redhat.com>
Thu, 6 Sep 2018 15:28:45 +0000 (10:28 -0500)
Note the time when the active mgr changes (added or removed).

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/MgrMap.h
src/mon/MgrMonitor.cc

index 592f7e58c7f2521b9c6c04638f7b7484cace4b60..ee17f2081d9b54100f8bae34a6bd769a468ce679 100644 (file)
@@ -137,6 +137,8 @@ public:
   bool available = false;
   /// the name (foo in mgr.<foo>) of the active daemon
   std::string active_name;
+  /// when the active mgr became active, or we lost the active mgr
+  utime_t active_change;
 
   std::map<uint64_t, StandbyInfo> standbys;
 
@@ -155,6 +157,7 @@ public:
   uint64_t get_active_gid() const { return active_gid; }
   bool get_available() const { return available; }
   const std::string &get_active_name() const { return active_name; }
+  const utime_t& get_active_change() const { return active_change; }
 
   bool all_support_module(const std::string& module) {
     if (!have_module(module)) {
@@ -258,7 +261,7 @@ public:
       ENCODE_FINISH(bl);
       return;
     }
-    ENCODE_START(6, 6, bl);
+    ENCODE_START(7, 6, bl);
     encode(epoch, bl);
     encode(active_addrs, bl, features);
     encode(active_gid, bl);
@@ -268,13 +271,14 @@ public:
     encode(modules, bl);
     encode(services, bl);
     encode(available_modules, bl);
+    encode(active_change, bl);
     ENCODE_FINISH(bl);
     return;
   }
 
   void decode(bufferlist::const_iterator& p)
   {
-    DECODE_START(6, p);
+    DECODE_START(7, p);
     decode(epoch, p);
     decode(active_addrs, p);
     decode(active_gid, p);
@@ -305,6 +309,11 @@ public:
     if (struct_v >= 4) {
       decode(available_modules, p);
     }
+    if (struct_v >= 7) {
+      decode(active_change, p);
+    } else {
+      active_change = {};
+    }
     DECODE_FINISH(p);
   }
 
@@ -313,6 +322,7 @@ public:
     f->dump_int("active_gid", get_active_gid());
     f->dump_string("active_name", get_active_name());
     f->dump_object("active_addrs", active_addrs);
+    f->dump_stream("active_change") << active_change;
     f->dump_bool("available", available);
     f->open_array_section("standbys");
     for (const auto &i : standbys) {
index 3b4d0c279411cf97ca6026d6e77d23f5e4f86d77..c02088d4cc29e2fb4101537bcb8a942a68a69722 100644 (file)
@@ -409,6 +409,7 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op)
            << pending_map.active_name << ")" << dendl;
     pending_map.active_gid = m->get_gid();
     pending_map.active_name = m->get_name();
+    pending_map.active_change = ceph_clock_now();
     pending_map.available_modules = m->get_available_modules();
     encode(m->get_metadata(), pending_metadata[m->get_name()]);
     pending_metadata_rm.erase(m->get_name());
@@ -666,6 +667,7 @@ bool MgrMonitor::promote_standby()
     pending_map.active_name = pending_map.standbys.at(replacement_gid).name;
     pending_map.available = false;
     pending_map.active_addrs = entity_addrvec_t();
+    pending_map.active_change = ceph_clock_now();
 
     drop_standby(replacement_gid, false);
 
@@ -685,6 +687,7 @@ void MgrMonitor::drop_active()
   pending_metadata.erase(pending_map.active_name);
   pending_map.active_name = "";
   pending_map.active_gid = 0;
+  pending_map.active_change = ceph_clock_now();
   pending_map.available = false;
   pending_map.active_addrs = entity_addrvec_t();
   pending_map.services.clear();