]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_mon: use default port when not specified
authorLi Wang <laurence.liwang@gmail.com>
Wed, 6 Sep 2017 14:35:48 +0000 (14:35 +0000)
committerLi Wang <laurence.liwang@gmail.com>
Fri, 29 Sep 2017 08:03:11 +0000 (08:03 +0000)
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 <laurence.liwang@gmail.com>
src/ceph_mon.cc

index 3663bb04e4b3c3e71dc20bace01969fcb92eb7ee..edf262753ca0c94d9cb4929d1888e0a7366c8de8 100644 (file)
@@ -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 {