From: Patrick Donnelly Date: Mon, 18 Sep 2023 14:58:12 +0000 (-0400) Subject: mon/MDSMonitor: set birth time on FSMap during encode X-Git-Tag: testing/wip-jcollin-testing-20240711.095637-squid~7^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e0f033cb5a0c466cdf85064afce3be593c249104;p=ceph-ci.git mon/MDSMonitor: set birth time on FSMap during encode 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 (cherry picked from commit 7637b199ebd6291e96c99d36cecda785c0608f76) --- diff --git a/qa/tasks/mgr/dashboard/test_health.py b/qa/tasks/mgr/dashboard/test_health.py index 5b181968633..51f51d2f366 100644 --- a/qa/tasks/mgr/dashboard/test_health.py +++ b/qa/tasks/mgr/dashboard/test_health.py @@ -186,6 +186,7 @@ class HealthTest(DashboardTestCase): }) }), 'fs_map': JObj({ + 'btime': str, 'compat': JObj({ 'compat': JObj({}, allow_unknown=True, unknown_schema=str), 'incompat': JObj( diff --git a/src/mds/FSMap.cc b/src/mds/FSMap.cc index a266ad253af..e5647dd80c7 100644 --- a/src/mds/FSMap.cc +++ b/src/mds/FSMap.cc @@ -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& 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()); @@ -638,6 +642,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); } @@ -669,6 +674,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); } diff --git a/src/mds/FSMap.h b/src/mds/FSMap.h index e2046fb7af8..c7e699dfa3b 100644 --- a/src/mds/FSMap.h +++ b/src/mds/FSMap.h @@ -26,6 +26,7 @@ #include #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; 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), @@ -578,6 +581,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; @@ -670,6 +680,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; diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 357f944df21..9dd72152327 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -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()); diff --git a/src/pybind/mgr/dashboard/controllers/health.py b/src/pybind/mgr/dashboard/controllers/health.py index 3edc386b012..de45bebbb46 100644 --- a/src/pybind/mgr/dashboard/controllers/health.py +++ b/src/pybind/mgr/dashboard/controllers/health.py @@ -44,6 +44,7 @@ HEALTH_MINIMAL_SCHEMA = ({ 'failed': ([int], ''), 'metadata_pool': (int, ''), 'epoch': (int, ''), + 'btime': (str, ''), 'stopped': ([int], ''), 'max_mds': (int, ''), 'compat': ({ diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml index 1b7d012eb84..1a10bfe3627 100644 --- a/src/pybind/mgr/dashboard/openapi.yaml +++ b/src/pybind/mgr/dashboard/openapi.yaml @@ -4930,6 +4930,9 @@ paths: balancer: description: '' type: string + btime: + description: '' + type: string compat: description: '' properties: @@ -5049,6 +5052,7 @@ paths: - failed - metadata_pool - epoch + - btime - stopped - max_mds - compat