]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/ConfigMonitor: make legacy mon addr/port parseable by legacy code
authorSage Weil <sage@redhat.com>
Sun, 22 Dec 2019 01:53:14 +0000 (19:53 -0600)
committerSage Weil <sage@redhat.com>
Sun, 22 Dec 2019 01:53:38 +0000 (19:53 -0600)
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 <sage@redhat.com>
src/mon/ConfigMonitor.cc

index a8ca0c668925d640f4e18c6b7044de8f1d83620a..96332c0059c25c013cf99862999a9f91b6bf007b 100644 (file)
@@ -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();