From: Kefu Chai Date: Thu, 21 Jan 2021 12:35:55 +0000 (+0800) Subject: crimson/mon: fallback to msgr v2 for unbound msgr X-Git-Tag: v17.0.0~4^2~7 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=264e710a374f24bfa4d8891cf39b9ae5e6075ac6;p=ceph-ci.git crimson/mon: fallback to msgr v2 for unbound msgr so, for instance, if we want to connect to monitor without bind to any address, we can try to use the v2 addresses advertised in monmap or local settings, instead of being unable to connect to mon because we are using an `entity_addr_t::TYPE_NONE` address which is returned by `entity_addrvec_t::front()` if the addrvec is empty. see also AsyncMessenger::should_use_msgr2(). Signed-off-by: Kefu Chai --- diff --git a/src/crimson/mon/MonClient.cc b/src/crimson/mon/MonClient.cc index 7aa7b65f578..defa03f3422 100644 --- a/src/crimson/mon/MonClient.cc +++ b/src/crimson/mon/MonClient.cc @@ -957,7 +957,13 @@ seastar::future<> Client::reopen_session(int rank) pending_conns.reserve(mons.size()); return seastar::parallel_for_each(mons, [this](auto rank) { // TODO: connect to multiple addrs - auto peer = monmap.get_addrs(rank).pick_addr(msgr.get_myaddr().get_type()); + // connect to v2 addresses if we have not bound to any address, otherwise + // use the advertised msgr protocol + uint32_t type = msgr.get_myaddr().get_type(); + if (type == entity_addr_t::TYPE_NONE) { + type = entity_addr_t::TYPE_MSGR2; + } + auto peer = monmap.get_addrs(rank).pick_addr(type); if (peer == entity_addr_t{}) { // crimson msgr only uses the first bound addr logger().warn("mon.{} does not have an addr compatible with my type: {}",