From: Sage Weil Date: Mon, 6 Aug 2018 18:24:20 +0000 (-0500) Subject: mon/MgrMap: track active_changed timestamp X-Git-Tag: v14.0.1~357^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8a5c70dd669ba292468917dfe0f457180056ca93;p=ceph.git mon/MgrMap: track active_changed timestamp Note the time when the active mgr changes (added or removed). Signed-off-by: Sage Weil --- diff --git a/src/mon/MgrMap.h b/src/mon/MgrMap.h index 592f7e58c7f..ee17f2081d9 100644 --- a/src/mon/MgrMap.h +++ b/src/mon/MgrMap.h @@ -137,6 +137,8 @@ public: bool available = false; /// the name (foo in mgr.) 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 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) { diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index 3b4d0c27941..c02088d4cc2 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -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();