]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: MonmapMonitor: Use default port when the specified on 'add' is zero
authorJoao Eduardo Luis <joao.luis@inktank.com>
Wed, 27 Jun 2012 23:29:24 +0000 (00:29 +0100)
committerGreg Farnum <greg@inktank.com>
Wed, 27 Jun 2012 23:20:47 +0000 (16:20 -0700)
Fixes a bug triggered by using the ceph tool to 'mon add' with a port set
to zero. We now default to the monitor's default port (6789) instead, and
we will fail if that port is already assigned to some other monitor.

Fixes: bug #2661
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/mon/MonmapMonitor.cc

index d07714cd9a68b4df9647a52119f736735e4ca587..10605a9b60090b938d5b39c377d622b3ce9f6168 100644 (file)
@@ -310,9 +310,17 @@ bool MonmapMonitor::prepare_command(MMonCommand *m)
        ss << "addr " << m->cmd[3] << "does not parse";
        goto out;
       }
+
+      if (addr.get_port() == 0) {
+       ss << "port defaulted to " << CEPH_MON_PORT;
+       addr.set_port(CEPH_MON_PORT);
+      }
+
       if (pending_map.contains(addr) ||
          pending_map.contains(name)) {
        err = -EEXIST;
+       if (!ss.str().empty())
+         ss << "; ";
        ss << "mon " << name << " " << addr << " already exists";
        goto out;
       }