]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonMapMonitor: add 'mon enable-msgr2' command
authorSage Weil <sage@redhat.com>
Tue, 8 Jan 2019 22:54:21 +0000 (16:54 -0600)
committerSage Weil <sage@redhat.com>
Tue, 15 Jan 2019 16:42:29 +0000 (10:42 -0600)
This switches any monitor listening on v1:...:6789 only to v2 (on
3300) + v1 (on 6789).  It should be run after upgrading all monitors
to nautilus.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/MonCommands.h
src/mon/MonmapMonitor.cc

index 7e10e2628f39f59c189bdf8483508b8a407e9966..cf909f2939a22a53d3efc8c9f9040e23d0d5060f 100644 (file)
@@ -451,6 +451,9 @@ COMMAND("mon set-rank " \
        "name=rank,type=CephInt",
        "set the rank for the specified mon",
        "mon", "rw")
+COMMAND("mon enable-msgr2",
+       "enable the msgr2 protocol on port 3300",
+       "mon", "rw")
 
 /*
  * OSD commands
index 97e36e4914590e1f84a57de66eb0fb755b5d2a20..b3bb2f891794385696366d64154872a73d0da1c5 100644 (file)
@@ -732,6 +732,32 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op)
     pending_map.set_rank(name, rank);
     pending_map.last_changed = ceph_clock_now();
     propose = true;
+  } else if (prefix == "mon enable-msgr2") {
+    if (!monmap.get_required_features().contains_all(
+         ceph::features::mon::FEATURE_NAUTILUS)) {
+      err = -EACCES;
+      ss << "all monitors must be running nautilus to enable v2";
+      goto reply;
+    }
+    for (auto& i : pending_map.mon_info) {
+      if (i.second.public_addrs.v.size() == 1 &&
+         i.second.public_addrs.front().is_legacy() &&
+         i.second.public_addrs.front().get_port() == CEPH_MON_PORT_LEGACY) {
+       entity_addrvec_t av;
+       entity_addr_t a = i.second.public_addrs.front();
+       a.set_type(entity_addr_t::TYPE_MSGR2);
+       a.set_port(CEPH_MON_PORT_IANA);
+       av.v.push_back(a);
+       av.v.push_back(i.second.public_addrs.front());
+       dout(10) << " setting mon." << i.first
+                << " addrs " << i.second.public_addrs
+                << " -> " << av << dendl;
+       pending_map.set_addrvec(i.first, av);
+       propose = true;
+       pending_map.last_changed = ceph_clock_now();
+      }
+    }
+    err = 0;
   } else {
     ss << "unknown command " << prefix;
     err = -EINVAL;