]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/HealthMonitor: use timespan for mon_warn_older_version_delay
authorKefu Chai <kchai@redhat.com>
Thu, 10 Dec 2020 08:27:56 +0000 (16:27 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 11 Dec 2020 08:12:47 +0000 (16:12 +0800)
for better user experience

Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/standalone/misc/ver-health.sh
src/common/options.cc
src/mon/HealthMonitor.cc

index 3c480b2b105330a1452790a8e7695fdf60dc15a3..99b2a0834e5c51433caf5045de590fe90558d586 100755 (executable)
@@ -73,8 +73,8 @@ function TEST_check_version_health_1() {
     setup $dir || return 1
 
     # create a cluster with two monitors and three osds
-    run_mon $dir a --public-addr=$CEPH_MON_A --mon_warn_older_version_delay=0.0 || return 1
-    run_mon $dir b --public-addr=$CEPH_MON_B --mon_warn_older_version_delay=0.0 || return 1
+    run_mon $dir a --public-addr=$CEPH_MON_A --mon_warn_older_version_delay=0 || return 1
+    run_mon $dir b --public-addr=$CEPH_MON_B --mon_warn_older_version_delay=0 || return 1
     run_osd $dir 0 || return 1
     run_osd $dir 1 || return 1
     run_osd $dir 2 || return 1
@@ -119,8 +119,8 @@ function TEST_check_version_health_2() {
     setup $dir || return 1
 
     # create a cluster with all daemon types
-    run_mon $dir a --public-addr=$CEPH_MON_A --mon_warn_older_version_delay=0.0 || return 1
-    run_mon $dir b --public-addr=$CEPH_MON_B --mon_warn_older_version_delay=0.0 || return 1
+    run_mon $dir a --public-addr=$CEPH_MON_A --mon_warn_older_version_delay=0 || return 1
+    run_mon $dir b --public-addr=$CEPH_MON_B --mon_warn_older_version_delay=0 || return 1
     run_osd $dir 0 || return 1
     run_osd $dir 1 || return 1
     run_osd $dir 2 || return 1
@@ -135,7 +135,7 @@ function TEST_check_version_health_2() {
     ceph health detail | grep DAEMON_OLD_VERSION && return 1
 
     kill_daemons $dir KILL mon.b
-    ceph_debug_version_for_testing=01.00.00-gversion-test run_mon $dir b --mon_warn_older_version_delay=0.0
+    ceph_debug_version_for_testing=01.00.00-gversion-test run_mon $dir b --mon_warn_older_version_delay=0
     # XXX: Manager doesn't seem to use the test specific config for version
     #kill_daemons $dir KILL mgr.x
     #ceph_debug_version_for_testing=02.00.00-gversion-test run_mgr $dir x
index c029bc20358c2a499da5af377bfb17731e558097..2593366bbeb0fd7fc5eb0f5af5b80ae89a5f3d47 100644 (file)
@@ -2247,7 +2247,7 @@ std::vector<Option> get_global_options() {
     .add_service("mon")
     .set_description("issue DAEMON_OLD_VERSION health warning if daemons are not all running the same version"),
 
-    Option("mon_warn_older_version_delay", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
+    Option("mon_warn_older_version_delay", Option::TYPE_SECS, Option::LEVEL_ADVANCED)
     .set_default(7_day)
     .add_service("mon")
     .set_description("issue DAEMON_OLD_VERSION health warning after this amount of time has elapsed"),
index 953164df9e1d654d9c1d9f313f77d183f4f9ceed..b9f86161e5fae0d3210cfd7f452c590040211ca9 100644 (file)
@@ -706,12 +706,15 @@ bool HealthMonitor::check_leader_health()
 
 void HealthMonitor::check_for_older_version(health_check_map_t *checks)
 {
-  utime_t now = ceph_clock_now();
-  static utime_t old_version_first_time;
+  static ceph::coarse_mono_time old_version_first_time =
+    ceph::coarse_mono_clock::zero();
 
-  if (old_version_first_time == utime_t())
+  auto now = ceph::coarse_mono_clock::now();
+  if (ceph::coarse_mono_clock::is_zero(old_version_first_time)) {
     old_version_first_time = now;
-  if ((now - old_version_first_time) > g_conf().get_val<double>("mon_warn_older_version_delay")) {
+  }
+  const auto warn_delay = g_conf().get_val<std::chrono::seconds>("mon_warn_older_version_delay");
+  if (now - old_version_first_time > warn_delay) {
     std::map<string, std::list<string> > all_versions;
     mon.get_all_versions(all_versions);
     if (all_versions.size() > 1) {
@@ -747,7 +750,7 @@ void HealthMonitor::check_for_older_version(health_check_map_t *checks)
        d.detail.push_back(ds.str());
       }
     } else {
-      old_version_first_time = utime_t();
+      old_version_first_time = ceph::coarse_mono_clock::zero();
     }
   }
 }