From 4ad4118a1d8b573f9111d19ac906d46bbf0161ab Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 21 Dec 2019 19:53:14 -0600 Subject: [PATCH] mon/ConfigMonitor: make legacy mon addr/port parseable by legacy code If it's a v1 addr on the old default 6789 port, print it as a legacy-style addr (no v1: prefix) so that legacy code can parse it. Signed-off-by: Sage Weil --- src/mon/ConfigMonitor.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mon/ConfigMonitor.cc b/src/mon/ConfigMonitor.cc index a8ca0c66892..96332c0059c 100644 --- a/src/mon/ConfigMonitor.cc +++ b/src/mon/ConfigMonitor.cc @@ -388,7 +388,17 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op) if (i != mon->monmap->mon_info.begin()) { conf << " "; } - conf << i->second.public_addrs; + if (i->second.public_addrs.size() == 1 && + i->second.public_addrs.front().is_legacy() && + i->second.public_addrs.front().get_port() == CEPH_MON_PORT_LEGACY) { + // if this is a legacy addr on the legacy default port, then + // use the legacy-compatible formatting so that old clients + // can use this config. new code will see the :6789 and correctly + // interpret this as a v1 address. + conf << i->second.public_addrs.get_legacy_str(); + } else { + conf << i->second.public_addrs; + } } conf << "\n"; conf << config_map.global.get_minimal_conf(); -- 2.39.5