]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: use pick_addr() for picking peer addr 36323/head
authorKefu Chai <kchai@redhat.com>
Tue, 28 Jul 2020 12:32:59 +0000 (20:32 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 28 Jul 2020 12:48:01 +0000 (20:48 +0800)
in teuthology tests, there is good chance that we have ceph.conf
containing:

mon host = 172.21.15.122

which is translated to two monitors

- a: 172.21.15.122:3300
- a-legacy: 172.21.15.122:6789

both has protocol type of "any". so, to enable crimson to use settings
like this, we should let crimson to accept them, and drop the connection
if the peer claim to be using an incompatible protocol, when they are
exchanging banners.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/mgr/client.cc
src/crimson/mon/MonClient.cc

index e8666139dd811adf74830d23b57d7a2a8a760e44..1c8c3fd889f0e862fadb7d563b759525649a85d4 100644 (file)
@@ -103,14 +103,7 @@ seastar::future<> Client::reconnect()
   auto a_while = std::chrono::duration_cast<seastar::steady_clock_type::duration>(
     retry_interval);
   return seastar::sleep(a_while).then([this] {
-    auto peer = [&] {
-      auto& mgr_addrs = mgrmap.get_active_addrs();
-      if (msgr.get_myaddr().is_legacy()) {
-        return mgr_addrs.legacy_addr();
-      } else {
-        return mgr_addrs.msgr2_addr();
-      }
-    }();
+    auto peer = mgrmap.get_active_addrs().pick_addr(msgr.get_myaddr().get_type());
     if (peer == entity_addr_t{}) {
       // crimson msgr only uses the first bound addr
       logger().error("mgr.{} does not have an addr compatible with me",
index 179a16d7a07df02ac953a14c629adf549c14b523..ebce8bd3421ddc087f1d2bba7a261e768c4b777d 100644 (file)
@@ -953,14 +953,7 @@ seastar::future<> Client::reopen_session(int rank)
   pending_conns.reserve(mons.size());
   return seastar::parallel_for_each(mons, [this](auto rank) {
 #warning fixme
-    auto peer = [&] {
-      auto& mon_addrs = monmap.get_addrs(rank);
-      if (msgr.get_myaddr().is_legacy()) {
-        return mon_addrs.legacy_addr();
-      } else {
-        return mon_addrs.msgr2_addr();
-      }
-    }();
+    auto peer = monmap.get_addrs(rank).pick_addr(msgr.get_myaddr().get_type());
     if (peer == entity_addr_t{}) {
       // crimson msgr only uses the first bound addr
       logger().warn("mon.{} does not have an addr compatible with me", rank);