Skip to content

Commit

Permalink
mon/MonClient: send logs to mon on separate schedule than pings
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
liewegas committed Mar 4, 2020
1 parent 1f22faa commit 653e23f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/common/legacy_config_opts.h
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/common/options.cc
Expand Up @@ -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(""),
Expand Down
44 changes: 26 additions & 18 deletions src/mon/MonClient.cc
Expand Up @@ -890,10 +890,6 @@ void MonClient::tick()
{
ldout(cct, 10) << __func__ << dendl;

auto reschedule_tick = make_scope_guard([this] {
schedule_tick();
});

_check_auth_tickets();
_check_tell_commands();

Expand All @@ -913,23 +909,33 @@ 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;
}
}

auto reschedule_tick = make_scope_guard([this] {
schedule_tick();
});
}

void MonClient::_un_backoff()
Expand All @@ -951,7 +957,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);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/mon/MonClient.h
Expand Up @@ -280,6 +280,9 @@ class MonClient : public Dispatcher,
void handle_auth(MAuthReply *m);

// monitor session
utime_t last_keepalive;
utime_t last_send_log;

void tick();
void schedule_tick();

Expand Down

0 comments on commit 653e23f

Please sign in to comment.