]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonClient: send logs to mon on separate schedule than pings 33732/head
authorSage Weil <sage@redhat.com>
Wed, 4 Mar 2020 22:40:46 +0000 (16:40 -0600)
committerSage Weil <sage@redhat.com>
Fri, 6 Mar 2020 15:00:03 +0000 (09:00 -0600)
We want to ping every 10s, but if we have log messages queued up, we
should send those promptly.  Adjust the tick interval to be the min of
these two intervals, and wrap each chunk of work with a check for whether
enough time has passed.

This makes 'ceph -w' (or 'ceph -W $channel') *way* more responsive and
useful.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/legacy_config_opts.h
src/common/options.cc
src/mon/MonClient.cc
src/mon/MonClient.h

index fbe387230bf2430fea2c590384479753368de7b9..bee70445daadee514c1bd68b5689734d86d51fc9 100644 (file)
@@ -331,6 +331,7 @@ OPTION(auth_service_ticket_ttl, OPT_DOUBLE)
 OPTION(auth_debug, OPT_BOOL)          // if true, assert when weird things happen
 OPTION(mon_client_hunt_parallel, OPT_U32)   // how many mons to try to connect to in parallel during hunt
 OPTION(mon_client_hunt_interval, OPT_DOUBLE)   // try new mon every N seconds until we connect
+OPTION(mon_client_log_interval, OPT_DOUBLE)  // send logs every N seconds
 OPTION(mon_client_ping_interval, OPT_DOUBLE)  // ping every N seconds
 OPTION(mon_client_ping_timeout, OPT_DOUBLE)   // fail if we don't hear back
 OPTION(mon_client_hunt_interval_backoff, OPT_DOUBLE) // each time we reconnect to a monitor, double our timeout
index 449e5ea585c456866be03a5a8defcfc6457e5e80..16c36b243e131caff594a03aff2dbb891a2f3773 100644 (file)
@@ -2257,6 +2257,10 @@ std::vector<Option> get_global_options() {
     .set_default(3.0)
     .set_description(""),
 
+    Option("mon_client_log_interval", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
+    .set_default(1.0)
+    .set_description("How frequently we send queued cluster log messages to mon"),
+
     Option("mon_client_ping_interval", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
     .set_default(10.0)
     .set_description(""),
index 033d8a0085023e37e70c09644db9f50067966335..57fb9b1554f3e73744bdfb9a8ca3872d4b9e4f76 100644 (file)
@@ -890,6 +890,8 @@ void MonClient::tick()
 {
   ldout(cct, 10) << __func__ << dendl;
 
+  utime_t now = ceph_clock_now();
+
   auto reschedule_tick = make_scope_guard([this] {
       schedule_tick();
     });
@@ -902,7 +904,6 @@ void MonClient::tick()
     return _reopen_session();
   } else if (active_con) {
     // just renew as needed
-    utime_t now = ceph_clock_now();
     auto cur_con = active_con->get_con();
     if (!cur_con->has_feature(CEPH_FEATURE_MON_STATEFUL_SUB)) {
       const bool maybe_renew = sub.need_renew();
@@ -913,22 +914,28 @@ void MonClient::tick()
       }
     }
 
-    cur_con->send_keepalive();
-
-    if (cct->_conf->mon_client_ping_timeout > 0 &&
-       cur_con->has_feature(CEPH_FEATURE_MSGR_KEEPALIVE2)) {
-      utime_t lk = cur_con->get_last_keepalive_ack();
-      utime_t interval = now - lk;
-      if (interval > cct->_conf->mon_client_ping_timeout) {
-       ldout(cct, 1) << "no keepalive since " << lk << " (" << interval
-                     << " seconds), reconnecting" << dendl;
-       return _reopen_session();
+    if (now > last_keepalive + cct->_conf->mon_client_ping_interval) {
+      cur_con->send_keepalive();
+      last_keepalive = now;
+
+      if (cct->_conf->mon_client_ping_timeout > 0 &&
+         cur_con->has_feature(CEPH_FEATURE_MSGR_KEEPALIVE2)) {
+       utime_t lk = cur_con->get_last_keepalive_ack();
+       utime_t interval = now - lk;
+       if (interval > cct->_conf->mon_client_ping_timeout) {
+         ldout(cct, 1) << "no keepalive since " << lk << " (" << interval
+                       << " seconds), reconnecting" << dendl;
+         return _reopen_session();
+       }
       }
-    }
 
-    _un_backoff();
+      _un_backoff();
+    }
 
-    send_log();
+    if (now > last_send_log + cct->_conf->mon_client_log_interval) {
+      send_log();
+      last_send_log = now;
+    }
   }
 }
 
@@ -951,7 +958,9 @@ void MonClient::schedule_tick()
                                reopen_interval_multiplier);
     timer.add_event_after(hunt_interval, do_tick);
   } else {
-    timer.add_event_after(cct->_conf->mon_client_ping_interval, do_tick);
+    timer.add_event_after(std::min(cct->_conf->mon_client_ping_interval,
+                                  cct->_conf->mon_client_log_interval),
+                         do_tick);
   }
 }
 
index 7a080f564d48df9da9a6457534126d85d91e70c6..b04db11f1350b2b90ed7512c8a60458450106241 100644 (file)
@@ -280,6 +280,9 @@ private:
   void handle_auth(MAuthReply *m);
 
   // monitor session
+  utime_t last_keepalive;
+  utime_t last_send_log;
+
   void tick();
   void schedule_tick();