From 3892d1beeb77f3ccbe720e4458246f515d974cbf Mon Sep 17 00:00:00 2001 From: Li Wang Date: Wed, 6 Sep 2017 14:35:48 +0000 Subject: [PATCH] ceph_mon: use default port when not specified If the monitor port is not specified in ceph.conf, it will use 0. However, monmaptool will use default port in creating monitor map in such case. The inconsistent behavior is not graceful, and every time monitor loading, it warns 'mon addr config option does not match monmap file', which is confusing. Signed-off-by: Li Wang --- src/ceph_mon.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index 3663bb04e4b3c..edf262753ca0c 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -627,10 +627,14 @@ int main(int argc, const char **argv) std::string mon_addr_str; if (g_conf->get_val_from_conf_file(my_sections, "mon addr", mon_addr_str, true) == 0) { - if (conf_addr.parse(mon_addr_str.c_str()) && (ipaddr != conf_addr)) { - derr << "WARNING: 'mon addr' config option " << conf_addr - << " does not match monmap file" << std::endl - << " continuing with monmap configuration" << dendl; + if (conf_addr.parse(mon_addr_str.c_str())) { + if (conf_addr.get_port() == 0) + conf_addr.set_port(CEPH_MON_PORT); + if (ipaddr != conf_addr) { + derr << "WARNING: 'mon addr' config option " << conf_addr + << " does not match monmap file" << std::endl + << " continuing with monmap configuration" << dendl; + } } } } else { -- 2.39.5