]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd mon mgr: Changes for rebase and correction for this branch
authorDavid Zafman <dzafman@redhat.com>
Fri, 26 Jul 2019 05:23:21 +0000 (22:23 -0700)
committerDavid Zafman <dzafman@redhat.com>
Sat, 19 Oct 2019 17:53:27 +0000 (10:53 -0700)
Fix use of asok_command() which doesn't do try/catch
Need unregister_command() since unregister_commands() doesn't exist here
Use Mutex::locker since lock_guard() isn't available
Use new g_conf which isn't g_conf() anymore
cct->_conf is a pointer now
Use ceph_abort() because cct isn't available for ceph_abort_msg()

Signed-off-by: David Zafman <dzafman@redhat.com>
src/mgr/ClusterState.cc
src/mon/PGMap.cc
src/osd/OSD.cc
src/osd/OSD.h

index 5b7d5948ef2f9f3186db36c7bc081c27a9a0511f..ef04a22a5ad7920b46aa48344d6084cc5deaef7e 100644 (file)
@@ -174,13 +174,7 @@ public:
   bool call(std::string_view admin_command, const cmdmap_t& cmdmap,
            std::string_view format, bufferlist& out) override {
     stringstream ss;
-    bool r = true;
-    try {
-      r = cluster_state->asok_command(admin_command, cmdmap, format, ss);
-    } catch (const bad_cmd_get& e) {
-      ss << e.what();
-      r = true;
-    }
+    bool r = cluster_state->asok_command(admin_command, cmdmap, format, ss);
     out.append(ss);
     return r;
   }
@@ -199,7 +193,7 @@ void ClusterState::final_init()
 void ClusterState::shutdown()
 {
   // unregister commands
-  g_ceph_context->get_admin_socket()->unregister_commands(asok_hook);
+  g_ceph_context->get_admin_socket()->unregister_command("dump_osd_network");
   delete asok_hook;
   asok_hook = NULL;
 }
@@ -207,17 +201,17 @@ void ClusterState::shutdown()
 bool ClusterState::asok_command(std::string_view admin_command, const cmdmap_t& cmdmap,
                       std::string_view format, ostream& ss)
 {
-  std::lock_guard l(lock);
+  Mutex::Locker l(lock);
   Formatter *f = Formatter::create(format, "json-pretty", "json-pretty");
   if (admin_command == "dump_osd_network") {
     int64_t value = 0;
     // Default to health warning level if nothing specified
     if (!(cmd_getval(g_ceph_context, cmdmap, "value", value))) {
       // Convert milliseconds to microseconds
-      value = static_cast<int64_t>(g_ceph_context->_conf.get_val<double>("mon_warn_on_slow_ping_time")) * 1000;
+      value = static_cast<int64_t>(g_ceph_context->_conf->get_val<double>("mon_warn_on_slow_ping_time")) * 1000;
       if (value == 0) {
-        double ratio = g_conf().get_val<double>("mon_warn_on_slow_ping_ratio");
-       value = g_conf().get_val<int64_t>("osd_heartbeat_grace");
+        double ratio = g_conf->get_val<double>("mon_warn_on_slow_ping_ratio");
+       value = g_conf->get_val<int64_t>("osd_heartbeat_grace");
        value *= 1000000 * ratio; // Seconds of grace to microseconds at ratio
       }
     } else {
@@ -262,7 +256,7 @@ bool ClusterState::asok_command(std::string_view admin_command, const cmdmap_t&
 
        if (j.second.last_update == 0)
          continue;
-       auto stale_time = g_ceph_context->_conf.get_val<int64_t>("osd_mon_heartbeat_stat_stale");
+       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;
@@ -326,7 +320,7 @@ bool ClusterState::asok_command(std::string_view admin_command, const cmdmap_t&
       char buffer[26];
       string lustr(ctime_r(&lu, buffer));
       lustr.pop_back();   // Remove trailing \n
-      auto stale = g_ceph_context->_conf.get_val<int64_t>("osd_heartbeat_stale");
+      auto stale = g_ceph_context->_conf->get_val<int64_t>("osd_heartbeat_stale");
       f->dump_string("last update", lustr);
       f->dump_bool("stale", ceph_clock_now().sec() - sitem.last_update > stale);
       f->dump_int("from osd", sitem.from);
@@ -353,7 +347,7 @@ bool ClusterState::asok_command(std::string_view admin_command, const cmdmap_t&
     f->close_section(); // entries
     f->close_section(); // network_ping_times
   } else {
-    ceph_abort_msg("broken asok registration");
+    ceph_abort();
   }
   f->flush(ss);
   delete f;
index 0db450a9b33439f36b9066cbb5d28656387748fe..3649fb08dd5da5c8c81d4bce98c091da255b58b7 100644 (file)
@@ -2582,10 +2582,10 @@ void PGMap::get_health_checks(
 
   // SLOW_PING_TIME
   // Convert milliseconds to microseconds
-  auto warn_slow_ping_time = cct->_conf.get_val<double>("mon_warn_on_slow_ping_time") * 1000;
-  auto grace = cct->_conf.get_val<int64_t>("osd_heartbeat_grace");
+  auto warn_slow_ping_time = cct->_conf->get_val<double>("mon_warn_on_slow_ping_time") * 1000;
+  auto grace = cct->_conf->get_val<int64_t>("osd_heartbeat_grace");
   if (warn_slow_ping_time == 0) {
-    double ratio = cct->_conf.get_val<double>("mon_warn_on_slow_ping_ratio");
+    double ratio = cct->_conf->get_val<double>("mon_warn_on_slow_ping_ratio");
     warn_slow_ping_time = grace;
     warn_slow_ping_time *= 1000000 * ratio; // Seconds of grace to microseconds at ratio
   }
index 61db02ec095b926a6a59f2a4d6fd4acdf123861c..adf864b2c22b66360e63ac9d2cd301e0a3472ebd 100644 (file)
@@ -810,7 +810,7 @@ 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");
+  auto stale_time = g_conf->get_val<int64_t>("osd_mon_heartbeat_stat_stale");
   Mutex::Locker l(stat_lock);
   osd_stat.hb_peers.swap(hb_peers);
   osd->op_tracker.get_age_ms_histogram(&osd_stat.op_queue_age_hist);
@@ -2301,10 +2301,10 @@ will start to track new ops received afterwards.";
     int64_t value = 0;
     if (!(cmd_getval(cct, cmdmap, "value", value))) {
       // Convert milliseconds to microseconds
-      value = static_cast<int64_t>(g_conf().get_val<double>("mon_warn_on_slow_ping_time")) * 1000;
+      value = static_cast<int64_t>(g_conf->get_val<double>("mon_warn_on_slow_ping_time")) * 1000;
       if (value == 0) {
-        double ratio = g_conf().get_val<double>("mon_warn_on_slow_ping_ratio");
-        value = g_conf().get_val<int64_t>("osd_heartbeat_grace");
+        double ratio = g_conf->get_val<double>("mon_warn_on_slow_ping_ratio");
+        value = g_conf->get_val<int64_t>("osd_heartbeat_grace");
         value *= 1000000 * ratio; // Seconds of grace to microseconds at ratio
       }
     } else {
@@ -2397,7 +2397,7 @@ will start to track new ops received afterwards.";
       char buffer[26];
       string lustr(ctime_r(&lu, buffer));
       lustr.pop_back();   // Remove trailing \n
-      auto stale = cct->_conf.get_val<int64_t>("osd_heartbeat_stale");
+      auto stale = cct->_conf->get_val<int64_t>("osd_heartbeat_stale");
       f->dump_string("last update", lustr);
       f->dump_bool("stale", ceph_clock_now().sec() - sitem.last_update > stale);
       f->dump_int("from osd", whoami);
@@ -4818,8 +4818,8 @@ void OSD::handle_osd_ping(MOSDPing *m)
            if (i->second.hb_interval_start == utime_t())
              i->second.hb_interval_start = now;
            int64_t hb_avg_time_period = 60;
-           if (cct->_conf.get_val<int64_t>("debug_heartbeat_testing_span")) {
-             hb_avg_time_period = cct->_conf.get_val<int64_t>("debug_heartbeat_testing_span");
+           if (cct->_conf->get_val<int64_t>("debug_heartbeat_testing_span")) {
+             hb_avg_time_period = cct->_conf->get_val<int64_t>("debug_heartbeat_testing_span");
            }
            if (now - i->second.hb_interval_start >=  utime_t(hb_avg_time_period, 0)) {
               uint32_t back_avg = i->second.hb_total_back / i->second.hb_average_count;
@@ -4862,7 +4862,7 @@ void OSD::handle_osd_ping(MOSDPing *m)
              }
 
              {
-               std::lock_guard l(service.stat_lock);
+               Mutex::Locker l(service.stat_lock);
                service.osd_stat.hb_pingtime[from].last_update = now.sec();
                service.osd_stat.hb_pingtime[from].back_last =  back_pingtime;
 
@@ -4918,7 +4918,7 @@ void OSD::handle_osd_ping(MOSDPing *m)
                }
              }
            } else {
-               std::lock_guard l(service.stat_lock);
+               Mutex::Locker l(service.stat_lock);
                service.osd_stat.hb_pingtime[from].back_last =  back_pingtime;
                 if (i->second.con_front != NULL)
                  service.osd_stat.hb_pingtime[from].front_last = front_pingtime;
@@ -4986,7 +4986,7 @@ void OSD::heartbeat_entry()
     heartbeat();
 
     double wait;
-    if (cct->_conf.get_val<bool>("debug_disable_randomized_ping")) {
+    if (cct->_conf->get_val<bool>("debug_disable_randomized_ping")) {
       wait = (float)cct->_conf->osd_heartbeat_interval;
     } else {
       wait = .5 + ((float)(rand() % 10)/10.0) * (float)cct->_conf->osd_heartbeat_interval;
index 81eabebc74d66d1fdf327395bc721a931a21d40a..4a04d3ba52553b80a3b30389123eb58f740d49b8 100644 (file)
@@ -899,7 +899,7 @@ public:
   }
   void get_hb_pingtime(map<int, osd_stat_t::Interfaces> *pp)
   {
-    std::lock_guard l(stat_lock);
+    Mutex::Locker l(stat_lock);
     *pp = osd_stat.hb_pingtime;
     return;
   }