]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd mgr: Add osd_mon_heartbeat_stat_stale option to time out ping info
authorDavid Zafman <dzafman@redhat.com>
Mon, 22 Jul 2019 18:52:41 +0000 (11:52 -0700)
committerDavid Zafman <dzafman@redhat.com>
Mon, 4 Nov 2019 22:21:21 +0000 (14:21 -0800)
after 1 hour

Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit 048f8096265dd3a647adb970255e4b11c9617b2e)

doc/rados/configuration/mon-osd-interaction.rst
src/common/options.cc
src/mgr/ClusterState.cc
src/osd/OSD.cc

index 42be922fec0b51e561feab6a144e25cc7c2c4c9a..a7324ebb0e5541e996e69f8140a3e0ab71e24398 100644 (file)
@@ -377,6 +377,15 @@ OSD Settings
 :Default: ``30``
 
 
+``osd mon heartbeat stat stale``
+
+:Description: Stop reporting on heartbeat ping times which haven't been updated for
+              this many seconds.  Set to zero to disable this action.
+
+:Type: 32-bit Integer
+:Default: ``3600``
+
+
 ``osd mon report interval``
 
 :Description: The number of seconds a Ceph OSD Daemon may wait
index 9df42fc86980d20fafac03050cbee6a0b5e7350a..889778c433dfc9381203ac9cc9189d3d0a07edaf 100644 (file)
@@ -3393,6 +3393,11 @@ std::vector<Option> get_global_options() {
     .set_default(30)
     .set_description(""),
 
+    Option("osd_mon_heartbeat_stat_stale", Option::TYPE_INT, Option::LEVEL_ADVANCED)
+    .set_default(1_hr)
+    .set_description("Stop reporting on heartbeat ping times not updated for this many seconds.")
+    .set_long_description("Stop reporting on old heartbeat information unless this is set to zero"),
+
     Option("osd_mon_report_interval", Option::TYPE_INT, Option::LEVEL_ADVANCED)
     .set_default(5)
     .set_description("Frequency of OSD reports to mon for peer failures, fullness status changes"),
index 140c1744d61020c7ffe45a27c16a4de3feb412e3..f38ff04321948b858c09e45d335090625cb3b0ab 100644 (file)
@@ -263,8 +263,18 @@ bool ClusterState::asok_command(std::string_view admin_command, const cmdmap_t&
     };
 
     set<mgr_ping_time_t> sorted;
+    utime_t now = ceph_clock_now();
     for (auto i : pg_map.osd_stat) {
       for (auto j : i.second.hb_pingtime) {
+
+       if (j.second.last_update == 0)
+         continue;
+       auto stale_time = g_ceph_context->_conf.get_val<int64_t>("osd_mon_heartbeat_stat_stale");
+       if (now.sec() - j.second.last_update > stale_time) {
+         dout(20) << __func__ << " time out heartbeat for osd " << i.first
+                  << " last_update " << j.second.last_update << dendl;
+          continue;
+       }
        mgr_ping_time_t item;
        item.pingtime = std::max(j.second.back_pingtime[0], j.second.back_pingtime[1]);
        item.pingtime = std::max(item.pingtime, j.second.back_pingtime[2]);
index fa2de7925f2192c5f6005b1f9b9c995e6755160c..935c5fa63b823696a6f7f61810b55b06b2573c0b 100644 (file)
@@ -941,10 +941,24 @@ void OSDService::set_statfs(const struct store_statfs_t &stbuf,
 osd_stat_t OSDService::set_osd_stat(vector<int>& hb_peers,
                                    int num_pgs)
 {
+  utime_t now = ceph_clock_now();
+  auto stale_time = g_conf().get_val<int64_t>("osd_mon_heartbeat_stat_stale");
   std::lock_guard l(stat_lock);
   osd_stat.hb_peers.swap(hb_peers);
   osd->op_tracker.get_age_ms_histogram(&osd_stat.op_queue_age_hist);
   osd_stat.num_pgs = num_pgs;
+  // Clean entries that aren't updated
+  // This is called often enough that we can just remove 1 at a time
+  for (auto i: osd_stat.hb_pingtime) {
+    if (i.second.last_update == 0)
+      continue;
+    if (stale_time && now.sec() - i.second.last_update > stale_time) {
+      dout(20) << __func__ << " time out heartbeat for osd " << i.first
+              << " last_update " << i.second.last_update << dendl;
+      osd_stat.hb_pingtime.erase(i.first);
+      break;
+    }
+  }
   return osd_stat;
 }
 
@@ -2754,6 +2768,8 @@ will start to track new ops received afterwards.";
     map<int, osd_stat_t::Interfaces> *pingtimes = new map<int, osd_stat_t::Interfaces>;
     service.get_hb_pingtime(pingtimes);
     for (auto j : *pingtimes) {
+      if (j.second.last_update == 0)
+       continue;
       osd_ping_time_t item;
       item.pingtime = std::max(j.second.back_pingtime[0], j.second.back_pingtime[1]);
       item.pingtime = std::max(item.pingtime, j.second.back_pingtime[2]);