]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon/MonmapMonitor: add 'ceph mon set-addrs <name> <addrvec>' command
authorSage Weil <sage@redhat.com>
Wed, 6 Mar 2019 22:21:31 +0000 (16:21 -0600)
committerSage Weil <sage@redhat.com>
Thu, 7 Mar 2019 22:35:35 +0000 (16:35 -0600)
This lets us explicitly adjust the IPs/ports a monitor binds to.

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

index d03b901dcb284f3c896fa4a7f8edf02981af9ec8..38f605bed9b032f4c2717620a5e21997f0bc5e83 100644 (file)
@@ -458,6 +458,11 @@ COMMAND("mon set-rank " \
        "name=rank,type=CephInt",
        "set the rank for the specified mon",
        "mon", "rw")
+COMMAND("mon set-addrs " \
+       "name=name,type=CephString " \
+       "name=addrs,type=CephString",
+       "set the addrs (IPs and ports) a specific monitor binds to",
+       "mon", "rw")
 COMMAND("mon enable-msgr2",
        "enable the msgr2 protocol on port 3300",
        "mon", "rw")
index 0c44894dab1e55e97cd97be47c154dcd8a5d28d8..9298f24421120a69f4e9ad3b3fd0558d8f9532ec 100644 (file)
@@ -751,6 +751,37 @@ 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 set-addrs") {
+    string name;
+    string addrs;
+    if (!cmd_getval(g_ceph_context, cmdmap, "name", name) ||
+       !cmd_getval(g_ceph_context, cmdmap, "addrs", addrs)) {
+      err = -EINVAL;
+      goto reply;
+    }
+    if (!pending_map.contains(name)) {
+      ss << "mon." << name << " does not exist";
+      err = -ENOENT;
+      goto reply;
+    }
+    entity_addrvec_t av;
+    if (!av.parse(addrs.c_str(), nullptr)) {
+      ss << "failed to parse addrs '" << addrs << "'";
+      err = -EINVAL;
+      goto reply;
+    }
+    for (auto& a : av.v) {
+      a.set_nonce(0);
+      if (!a.get_port()) {
+       ss << "monitor must bind to a non-zero port, not " << a;
+       err = -EINVAL;
+       goto reply;
+      }
+    }
+    err = 0;
+    pending_map.set_addrvec(name, av);
+    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)) {