From: huangjun Date: Thu, 3 Sep 2015 11:10:03 +0000 (+0800) Subject: mon/MonClient: fix error in 'ceph ping mon.id' X-Git-Tag: v9.1.0~171^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=557e581a4efbd47427846613c1f4d78598e9fbc0;p=ceph.git mon/MonClient: fix error in 'ceph ping mon.id' Fixes: #12442 Signed-off-by: huangjun --- diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index 6624e6be3033..35c5e726c3ca 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -207,11 +207,18 @@ int MonClient::ping_monitor(const string &mon_id, string *result_reply) { ldout(cct, 10) << __func__ << dendl; - if (mon_id.empty()) { + string new_mon_id; + if (monmap.contains("noname-"+mon_id)) { + new_mon_id = "noname-"+mon_id; + } else { + new_mon_id = mon_id; + } + + if (new_mon_id.empty()) { ldout(cct, 10) << __func__ << " specified mon id is empty!" << dendl; return -EINVAL; - } else if (!monmap.contains(mon_id)) { - ldout(cct, 10) << __func__ << " no such monitor 'mon." << mon_id << "'" + } else if (!monmap.contains(new_mon_id)) { + ldout(cct, 10) << __func__ << " no such monitor 'mon." << new_mon_id << "'" << dendl; return -ENOENT; } @@ -224,8 +231,8 @@ int MonClient::ping_monitor(const string &mon_id, string *result_reply) smsgr->add_dispatcher_head(pinger); smsgr->start(); - ConnectionRef con = smsgr->get_connection(monmap.get_inst(mon_id)); - ldout(cct, 10) << __func__ << " ping mon." << mon_id + ConnectionRef con = smsgr->get_connection(monmap.get_inst(new_mon_id)); + ldout(cct, 10) << __func__ << " ping mon." << new_mon_id << " " << con->get_peer_addr() << dendl; con->send_message(new MPing);