]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: allow overriding the initial mon_host 36704/head
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 16 Sep 2020 19:28:55 +0000 (12:28 -0700)
committerShyamsundar Ranganathan <srangana@redhat.com>
Sun, 20 Sep 2020 11:37:18 +0000 (07:37 -0400)
This overrides what the CephContext believes to be the current quorum of
monitors (retrieved from other instances of the MonClient), introduced
by [1]. Tests need to be able to target a specific monitor for
exercising forwarding and other things.

[1] 731e2db9fb4611f767446a3c8e778a097ce70d35
Fixes: https://tracker.ceph.com/issues/47180
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
Signed-off-by: Shyamsundar Ranganathan <srangana@redhat.com>
(cherry picked from commit ed3782e60afa0da2f523fc6df7b593fe7a57646a)

Conflicts:
PendingReleaseNotes
Retained nautilus release notes with the required addition as above

PendingReleaseNotes
doc/rados/configuration/ceph-conf.rst
qa/standalone/mon/mon-handle-forward.sh
src/common/options.cc
src/mon/MonMap.cc

index 9d59a46d89a93da4b0c0a9a262e36573f94ccc2f..a1d23d68fb946a50d0954a86019d0e541527b16a 100644 (file)
@@ -11,3 +11,9 @@
   to be warned again if additional repairs are performed you can provide a value
   to the command and specify the value of ``mon_osd_warn_num_repaired``.
   This command will be replaced in future releases by the health mute/unmute feature.
+
+* It is now possible to specify the initial monitor to contact for Ceph tools
+  and daemons using the ``mon_host_override`` config option or
+  ``--mon-host-override <ip>`` command-line switch. This generally should only
+  be used for debugging and only affects initial communication with Ceph's
+  monitor cluster.
index 5b7264a8c765abd7a29891e8f8362bc8bece2d63..24c9afa46bee0727528c829824da8a4986aced0b 100644 (file)
@@ -65,6 +65,11 @@ configuration, they may need to be stored locally on the node and set
 in a local configuration file.  These options include:
 
   - ``mon_host``, the list of monitors for the cluster
+  - ``mon_host_override``, the list of monitors for the cluster to
+    **initially** contact when beginning a new instance of communication with the
+    Ceph cluster.  This overrides the known monitor list derived from MonMap
+    updates sent to older Ceph instances (like librados cluster handles).  It is
+    expected this option is primarily useful for debugging.
   - ``mon_dns_serv_name`` (default: `ceph-mon`), the name of the DNS
     SRV record to check to identify the cluster monitors via DNS
   - ``mon_data``, ``osd_data``, ``mds_data``, ``mgr_data``, and
index f067f46d9d7eb2457a0de93e1f924153b0223ce6..8633959d5f2a4a979e55688c3bccaa9ca99176a9 100755 (executable)
@@ -33,18 +33,18 @@ function run() {
         run_mon $dir b --public-addr $MONB || return 1
     )
 
-    timeout 360 ceph --mon-host $MONA mon stat || return 1
+    timeout 360 ceph --mon-host-override $MONA mon stat || return 1
     # check that MONB is indeed a peon
     ceph --admin-daemon $(get_asok_path mon.b) mon_status |
        grep '"peon"' || return 1
     # when the leader ( MONA ) is used, there is no message forwarding
-    ceph --mon-host $MONA osd pool create POOL1 12
+    ceph --mon-host-override $MONA osd pool create POOL1 12
     CEPH_ARGS='' ceph --admin-daemon $(get_asok_path mon.a) log flush || return 1
     grep 'mon_command(.*"POOL1"' $dir/mon.a.log || return 1
     CEPH_ARGS='' ceph --admin-daemon $(get_asok_path mon.b) log flush || return 1
     grep 'mon_command(.*"POOL1"' $dir/mon.b.log && return 1
     # when the peon ( MONB ) is used, the message is forwarded to the leader
-    ceph --mon-host $MONB osd pool create POOL2 12
+    ceph --mon-host-override $MONB osd pool create POOL2 12
     CEPH_ARGS='' ceph --admin-daemon $(get_asok_path mon.b) log flush || return 1
     grep 'forward_request.*mon_command(.*"POOL2"' $dir/mon.b.log || return 1
     CEPH_ARGS='' ceph --admin-daemon $(get_asok_path mon.a) log flush || return 1
index 3538f061abbf925aa6dd9bb574e3a794d035301c..83436034aa531cf7d2404ed1d632e638bced5919 100644 (file)
@@ -419,6 +419,12 @@ std::vector<Option> get_global_options() {
     .set_flag(Option::FLAG_STARTUP)
     .add_service("common"),
 
+    Option("mon_host_override", Option::TYPE_STR, Option::LEVEL_ADVANCED)
+    .set_description("monitor(s) to use overriding the MonMap")
+    .set_flag(Option::FLAG_NO_MON_UPDATE)
+    .set_flag(Option::FLAG_STARTUP)
+    .add_service("common"),
+
     Option("mon_dns_srv_name", Option::TYPE_STR, Option::LEVEL_ADVANCED)
     .set_default("ceph-mon")
     .set_description("name of DNS SRV record to check for monitor addresses")
index 9ea47ffef4f2344bde573edbd5ed51b2f96706ec..19092d53262ca7826c169e43fb2c7df095840f9d 100644 (file)
@@ -790,6 +790,21 @@ int MonMap::build_initial(CephContext *cct, bool for_mkfs, ostream& errout)
 {
   const auto& conf = cct->_conf;
 
+  // mon_host_override?
+  auto mon_host_override = conf.get_val<std::string>("mon_host_override");
+  if (!mon_host_override.empty()) {
+    lgeneric_dout(cct, 1) << "Using mon_host_override " << mon_host_override << dendl;
+    auto ret = init_with_ips(mon_host_override, for_mkfs, "noname-");
+    if (ret == -EINVAL) {
+      ret = init_with_hosts(mon_host_override, for_mkfs, "noname-");
+    }
+    if (ret < 0) {
+      errout << "unable to parse addrs in '" << mon_host_override << "'"
+            << std::endl;
+    }
+    return ret;
+  }
+
   // cct?
   auto addrs = cct->get_mon_addrs();
   if (addrs != nullptr && (addrs->size() > 0)) {