From: Sage Weil Date: Fri, 8 Nov 2019 22:35:28 +0000 (-0600) Subject: ceph-mon: bind to public_addrv if set (before public_addr or public_network) X-Git-Tag: v15.1.0~948^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F31501%2Fhead;p=ceph.git ceph-mon: bind to public_addrv if set (before public_addr or public_network) This lets you specify a precise addrvec for the monitor to bind to, instead of inferring a v1 or v2 address from the port number, or assuming both with default ports, or v2 only with an unrecognized port. I unfortunately don't quite remember why I didn't make public_addr a ADDRVEC option way back in nautilus--I only remmeber that it was going to cause problems. Adding a separate addrv option here is safe. Signed-off-by: Sage Weil --- diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index 850a54e855fb..573453c2d671 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -354,6 +354,7 @@ int main(int argc, const char **argv) dout(10) << "public_network " << g_conf()->public_network << dendl; dout(10) << "public_addr " << g_conf()->public_addr << dendl; + dout(10) << "public_addrv " << g_conf()->public_addrv << dendl; common_init_finish(g_ceph_context); @@ -400,6 +401,14 @@ int main(int argc, const char **argv) if (monmap.contains(g_conf()->name.get_id())) { // hmm, make sure the ip listed exists on the current host? // maybe later. + } else if (!g_conf()->public_addrv.empty()) { + entity_addrvec_t av = g_conf()->public_addrv; + string name; + if (monmap.contains(av, &name)) { + monmap.rename(name, g_conf()->name.get_id()); + dout(0) << argv[0] << ": renaming mon." << name << " " << av + << " to mon." << g_conf()->name.get_id() << dendl; + } } else if (!g_conf()->public_addr.is_blank_ip()) { entity_addrvec_t av = make_mon_addrs(g_conf()->public_addr); string name; @@ -715,7 +724,10 @@ int main(int argc, const char **argv) dout(0) << g_conf()->name << " does not exist in monmap, will attempt to join an existing cluster" << dendl; pick_addresses(g_ceph_context, CEPH_PICK_ADDRESS_PUBLIC); - if (!g_conf()->public_addr.is_blank_ip()) { + if (!g_conf()->public_addrv.empty()) { + ipaddrs = g_conf()->public_addrv; + dout(0) << "using public_addrv " << ipaddrs << dendl; + } else if (!g_conf()->public_addr.is_blank_ip()) { ipaddrs = make_mon_addrs(g_conf()->public_addr); dout(0) << "using public_addr " << g_conf()->public_addr << " -> " << ipaddrs << dendl;