From: Sage Weil Date: Wed, 6 Mar 2019 22:21:31 +0000 (-0600) Subject: mon/MonmapMonitor: add 'ceph mon set-addrs ' command X-Git-Tag: v14.1.1~21^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a7907403576e4f29882b6b327c2a9b88b2811d1a;p=ceph-ci.git mon/MonmapMonitor: add 'ceph mon set-addrs ' command This lets us explicitly adjust the IPs/ports a monitor binds to. Signed-off-by: Sage Weil --- diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index d03b901dcb2..38f605bed9b 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -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") diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index 0c44894dab1..9298f244211 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -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)) {