]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MDSMonitor: set birth time on FSMap during encode
authorPatrick Donnelly <pdonnell@redhat.com>
Mon, 18 Sep 2023 14:58:12 +0000 (10:58 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 21 Jun 2024 01:32:56 +0000 (21:32 -0400)
So we can begin to answer questions like: when did we last see an MDS?

Fixes: https://tracker.ceph.com/issues/62849
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
qa/tasks/mgr/dashboard/test_health.py
src/mds/FSMap.cc
src/mds/FSMap.h
src/mon/MDSMonitor.cc
src/pybind/mgr/dashboard/controllers/health.py
src/pybind/mgr/dashboard/openapi.yaml

index 5b181968633c163408daba30e749bb25b678146e..51f51d2f36671a138b29ef6efb5adb61cea42810 100644 (file)
@@ -186,6 +186,7 @@ class HealthTest(DashboardTestCase):
                 })
             }),
             'fs_map': JObj({
+                'btime': str,
                 'compat': JObj({
                     'compat': JObj({}, allow_unknown=True, unknown_schema=str),
                     'incompat': JObj(
index 73e4151a9ae6d8264d44b14f6c430b33d02d6e42..77b2cf078860e4f9126eb1fc9e7244c4fc609877 100644 (file)
@@ -135,6 +135,7 @@ void Filesystem::dump(Formatter *f) const
 void FSMap::dump(Formatter *f) const
 {
   f->dump_int("epoch", epoch);
+  f->dump_string("btime", fmt::format("{}", btime));
   // Use 'default' naming to match 'set-default' CLI
   f->dump_int("default_fscid", legacy_client_fscid);
 
@@ -168,6 +169,7 @@ void FSMap::dump(Formatter *f) const
 FSMap &FSMap::operator=(const FSMap &rhs)
 {
   epoch = rhs.epoch;
+  btime = rhs.btime;
   next_filesystem_id = rhs.next_filesystem_id;
   legacy_client_fscid = rhs.legacy_client_fscid;
   default_compat = rhs.default_compat;
@@ -206,6 +208,7 @@ void FSMap::generate_test_instances(std::list<FSMap*>& ls)
 void FSMap::print(ostream& out) const
 {
   out << "e" << epoch << std::endl;
+  out << "btime " << fmt::format("{}", btime) << std::endl;
   out << "enable_multiple, ever_enabled_multiple: " << enable_multiple << ","
       << ever_enabled_multiple << std::endl;
   out << "default compat: " << default_compat << std::endl;
@@ -296,6 +299,7 @@ void FSMap::print_summary(Formatter *f, ostream *out) const
 {
   if (f) {
     f->dump_unsigned("epoch", get_epoch());
+    f->dump_string("btime", fmt::format("{}", btime));
     for (const auto& [fscid, fs] : filesystems) {
       f->dump_unsigned("id", fscid);
       f->dump_unsigned("up", fs.mds_map.up.size());
@@ -643,6 +647,7 @@ void FSMap::encode(bufferlist& bl, uint64_t features) const
   encode(standby_daemons, bl, features);
   encode(standby_epochs, bl);
   encode(ever_enabled_multiple, bl);
+  encode(btime, bl);
   ENCODE_FINISH(bl);
 }
 
@@ -674,6 +679,9 @@ void FSMap::decode(bufferlist::const_iterator& p)
   if (struct_v >= 7) {
     decode(ever_enabled_multiple, p);
   }
+  if (struct_v >= 8) {
+    decode(btime, p);
+  }
   DECODE_FINISH(p);
 }
 
index 9d452bb98d954540db314465da24e2171f850923..518d6273e44f635708e49a7e795d40fc1bb5ee5d 100644 (file)
@@ -26,6 +26,7 @@
 #include <errno.h>
 
 #include "include/types.h"
+#include "common/ceph_time.h"
 #include "common/Clock.h"
 #include "mds/MDSMap.h"
 
@@ -268,12 +269,13 @@ WRITE_CLASS_ENCODER_FEATURES(Filesystem)
 
 class FSMap {
 public:
+  using real_clock = ceph::real_clock;
   using mds_info_t = MDSMap::mds_info_t;
   using fsmap = typename std::map<fs_cluster_id_t, Filesystem>;
   using const_iterator = typename fsmap::const_iterator;
   using iterator = typename fsmap::iterator;
 
-  static const version_t STRUCT_VERSION = 7;
+  static const version_t STRUCT_VERSION = 8;
   static const version_t STRUCT_VERSION_TRIM_TO = 7;
 
   FSMap() : default_compat(MDSMap::get_compat_set_default()) {}
@@ -281,6 +283,7 @@ public:
   FSMap(const FSMap &rhs)
     :
       epoch(rhs.epoch),
+      btime(rhs.btime),
       next_filesystem_id(rhs.next_filesystem_id),
       legacy_client_fscid(rhs.legacy_client_fscid),
       default_compat(rhs.default_compat),
@@ -584,6 +587,13 @@ public:
   epoch_t get_epoch() const { return epoch; }
   void inc_epoch() { epoch++; }
 
+  void set_btime() {
+    btime = real_clock::now();
+  }
+  auto get_btime() const {
+    return btime;
+  }
+
   version_t get_struct_version() const { return struct_version; }
   bool is_struct_old() const {
     return struct_version < STRUCT_VERSION_TRIM_TO;
@@ -676,6 +686,8 @@ protected:
   }
 
   epoch_t epoch = 0;
+  ceph::real_time btime = real_clock::zero();
+
   uint64_t next_filesystem_id = FS_CLUSTER_ID_ANONYMOUS + 1;
   fs_cluster_id_t legacy_client_fscid = FS_CLUSTER_ID_NONE;
   CompatSet default_compat;
index 357f944df21aefd6920286a4167ab1e82ff04313..9dd72152327da7c93e79956eb8417afc607ab0d4 100644 (file)
@@ -238,6 +238,7 @@ void MDSMonitor::encode_pending(MonitorDBStore::TransactionRef t)
   if (!g_conf()->mon_mds_skip_sanity) {
     pending.sanity(true);
   }
+  pending.set_btime();
 
   // apply to paxos
   ceph_assert(get_last_committed() + 1 == pending.get_epoch());
index 3edc386b01232bfdda8f135c19ba9b3b9eda9f22..de45bebbb465ba12a929d1379900c3c5ade480dd 100644 (file)
@@ -44,6 +44,7 @@ HEALTH_MINIMAL_SCHEMA = ({
                 'failed': ([int], ''),
                 'metadata_pool': (int, ''),
                 'epoch': (int, ''),
+                'btime': (str, ''),
                 'stopped': ([int], ''),
                 'max_mds': (int, ''),
                 'compat': ({
index d98613b53d62746ee44789f05dc2e21789e915a4..abed604209e076be95ccc6d253f70deb28a28abd 100644 (file)
@@ -5008,6 +5008,9 @@ paths:
                                 balancer:
                                   description: ''
                                   type: string
+                                btime:
+                                  description: ''
+                                  type: string
                                 compat:
                                   description: ''
                                   properties:
@@ -5127,6 +5130,7 @@ paths:
                               - failed
                               - metadata_pool
                               - epoch
+                              - btime
                               - stopped
                               - max_mds
                               - compat