Skip to content

Commit

Permalink
mon/MonClient: apply timeout while fetching config
Browse files Browse the repository at this point in the history
The normal timeouts automatically apply during the authenticate() stage,
but not to the explicit wait for a config.  If we don't get that quickly
we shoudl retry another monitor because it is possible we will connect to
an out-of-quorum (or otherwise unresponsive) mon.

Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Mar 6, 2018
1 parent bee6ced commit 3c2b30e
Showing 1 changed file with 35 additions and 24 deletions.
59 changes: 35 additions & 24 deletions src/mon/MonClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ int MonClient::get_monmap_and_config()
ldout(cct, 10) << __func__ << dendl;
assert(!messenger);

int tries = 10;

utime_t interval;
interval.set_from_double(cct->_conf->mon_client_hunt_interval * 10);
interval.set_from_double(cct->_conf->mon_client_hunt_interval);

cct->init_crypto();

Expand All @@ -115,32 +117,41 @@ int MonClient::get_monmap_and_config()
messenger->add_dispatcher_head(this);
messenger->start();

r = init();
if (r < 0) {
goto out_msgr;
}
r = authenticate(cct->_conf->client_mount_timeout);
if (r < 0) {
goto out_shutdown;
}
if (!monmap.persistent_features.contains_all(
ceph::features::mon::FEATURE_MIMIC)) {
ldout(cct,10) << __func__ << " pre-mimic monitor, no config to fetch"
<< dendl;
r = 0;
} else {
Mutex::Locker l(monc_lock);
while (!got_config) {
ldout(cct,20) << __func__ << " waiting for config" << dendl;
map_cond.WaitInterval(monc_lock, interval);
while (tries-- > 0) {
r = init();
if (r < 0) {
goto out_msgr;
}
r = authenticate(cct->_conf->client_mount_timeout);
if (r == -ETIMEDOUT) {
shutdown();
continue;
}
if (got_config) {
ldout(cct,10) << __func__ << " success" << dendl;
if (r < 0) {
goto out_shutdown;
}
if (!monmap.persistent_features.contains_all(
ceph::features::mon::FEATURE_MIMIC)) {
ldout(cct,10) << __func__ << " pre-mimic monitor, no config to fetch"
<< dendl;
r = 0;
} else {
lderr(cct) << __func__ << " failed to get config" << dendl;
r = -EIO;
break;
}
{
Mutex::Locker l(monc_lock);
while (!got_config && r == 0) {
ldout(cct,20) << __func__ << " waiting for config" << dendl;
r = map_cond.WaitInterval(monc_lock, interval);
}
if (got_config) {
ldout(cct,10) << __func__ << " success" << dendl;
r = 0;
break;
}
}
lderr(cct) << __func__ << " failed to get config" << dendl;
shutdown();
continue;
}

out_shutdown:
Expand Down

0 comments on commit 3c2b30e

Please sign in to comment.