]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: consolidate 'sync force' commands
authorSage Weil <sage@redhat.com>
Fri, 11 Oct 2019 00:08:50 +0000 (19:08 -0500)
committerSage Weil <sage@redhat.com>
Sat, 12 Oct 2019 17:05:36 +0000 (12:05 -0500)
Replace the 'ceph [mon] sync force' commands and just use the asok
sync_force command instead.  This is a low-level command that nobody should
reasonsbly using except in an emergency, so do not bother with trying to
maintain compatibility; it's a bit rediculous that we had 3 variations of
this to being with!

Signed-off-by: Sage Weil <sage@redhat.com>
PendingReleaseNotes
doc/man/8/ceph.rst
qa/tasks/mon_thrash.py
qa/workunits/cephtool/test.sh
src/ceph_mon.cc
src/mon/MonCommands.h
src/mon/Monitor.cc
src/mon/Monitor.h

index 974796806b3e3cf3ced02756f1bc60fc6c5cf386..1df7e0c2d6a1513369b9c8775553605eb633faeb 100644 (file)
   fsck will warn but not fail on legacy stores, and repair will
   convert to per-pool stats.
 
+* The disaster-recovery related 'ceph mon sync force' command has been
+  replaced with 'ceph daemon <...> sync_force'.
+
 * The ``osd_recovery_max_active`` option now has
   ``osd_recovery_max_active_hdd`` and ``osd_recovery_max_active_ssd``
   variants, each with different default values for HDD and SSD-backed
index 455a350fe3325c37fa484ca79a44680e401f2855..beaa008cf55317a73d112617fb9d0db0d656e601 100644 (file)
@@ -1515,16 +1515,6 @@ Usage::
        ceph status
 
 
-sync force
-----------
-
-Forces sync of and clear monitor store.
-
-Usage::
-
-       ceph sync force {--yes-i-really-mean-it} {--i-know-what-i-am-doing}
-
-
 tell
 ----
 
index ed0940c4ebf2e2dff7a8972c5c6ad5db5bc3ff8e..67ee6f714098bb02bb25459d3a32660e300551e8 100644 (file)
@@ -167,11 +167,10 @@ class MonitorThrasher(Thrasher):
         Thrash the monitor specified.
         :param mon: monitor to thrash
         """
-        addr = self.ctx.ceph['ceph'].mons['mon.%s' % mon]
-        self.log('thrashing mon.{id}@{addr} store'.format(id=mon, addr=addr))
-        out = self.manager.raw_cluster_cmd('-m', addr, 'sync', 'force',
-                                           '--yes-i-really-mean-it',
-                                           '--i-know-what-i-am-doing')
+        self.log('thrashing mon.{id} store'.format(id=mon))
+        out = self.manager.raw_cluster_cmd(
+            'tell', 'mon.%s' % mon, 'sync_force',
+            '--yes-i-really-mean-it')
         j = json.loads(out)
         assert j['ret'] == 0, \
             'error forcing store sync on mon.{id}:\n{ret}'.format(
index ca6915615af5425ee3966ef59505fc3a87e3ab12..9aa31a24a1a1c5925278b746a57f89886f02e955 100755 (executable)
@@ -2595,7 +2595,6 @@ function test_mon_deprecated_commands()
   # current DEPRECATED commands are:
   #  ceph compact
   #  ceph scrub
-  #  ceph sync force
   #
   # Testing should be accomplished by setting
   # 'mon_debug_deprecated_as_obsolete = true' and expecting ENOTSUP for
@@ -2608,9 +2607,6 @@ function test_mon_deprecated_commands()
   expect_false ceph tell mon.a scrub 2> $TMPFILE
   check_response "\(EOPNOTSUPP\|ENOTSUP\): command is obsolete"
 
-  expect_false ceph tell mon.a sync force 2> $TMPFILE
-  check_response "\(EOPNOTSUPP\|ENOTSUP\): command is obsolete"
-
   ceph tell mon.a injectargs '--no-mon-debug-deprecated-as-obsolete'
 }
 
index 7e222892783a678d41fb36985443efcf0967a7f7..850a54e855fb83a688f616baea180d168ec61f51 100644 (file)
@@ -811,9 +811,11 @@ int main(int argc, const char **argv)
   if (force_sync) {
     derr << "flagging a forced sync ..." << dendl;
     ostringstream oss;
-    mon->sync_force(NULL, oss);
-    if (oss.tellp())
-      derr << oss.str() << dendl;
+    JSONFormatter jf(true);
+    mon->sync_force(&jf);
+    derr << "out:\n";
+    jf.flush(*_dout);
+    *_dout << dendl;
   }
 
   err = mon->preinit();
index af63793659ec7251744855e0e7c2eda188ef581c..e14c9fefbfae909d92c009de1e39d99506fd5890 100644 (file)
@@ -242,12 +242,6 @@ COMMAND("mon ok-to-rm " \
        "check whether removing the specified mon would break quorum",
        "mon", "r")
 
-COMMAND_WITH_FLAG("sync force " \
-       "name=yes_i_really_mean_it,type=CephBool,req=false " \
-       "name=i_know_what_i_am_doing,type=CephBool,req=false", \
-       "force sync of and clear monitor store", \
-        "mon", "rw", \
-        FLAG(NOFORWARD)|FLAG(DEPRECATED))
 COMMAND_WITH_FLAG("heap " \
             "name=heapcmd,type=CephChoices,strings=dump|start_profiler|stop_profiler|release|stats", \
             "show heap usage info (available only if compiled with tcmalloc)", \
@@ -273,12 +267,6 @@ COMMAND_WITH_FLAG("mon scrub",
     "scrub the monitor stores", \
     "mon", "rw", \
     FLAG(NONE))
-COMMAND_WITH_FLAG("mon sync force " \
-    "name=yes_i_really_mean_it,type=CephBool,req=false " \
-    "name=i_know_what_i_am_doing,type=CephBool,req=false", \
-    "force sync of and clear monitor store", \
-    "mon", "rw", \
-    FLAG(NOFORWARD))
 COMMAND("mon metadata name=id,type=CephString,req=false",
        "fetch metadata for mon <id>",
        "mon", "r")
index a4f6def716cad7d7d9b909afe54f85f5b291049e..aa1f9b95ffcb3691477cf0ff0d33c0afd4f85088 100644 (file)
@@ -319,9 +319,10 @@ int Monitor::do_admin_command(
       err << "are you SURE? this will mean the monitor store will be erased "
        "the next time the monitor is restarted.  pass "
        "'--yes-i-really-mean-it' if you really do.";
+      r = -EPERM;
       goto abort;
     }
-    sync_force(f, out);
+    sync_force(f);
   } else if (command.compare(0, 23, "add_bootstrap_peer_hint") == 0 ||
             command.compare(0, 24, "add_bootstrap_peer_hintv") == 0) {
     if (!_add_bootstrap_peer_hint(command, cmdmap, out))
@@ -827,11 +828,12 @@ int Monitor::preinit()
   r = admin_socket->register_command("quorum_status",
                                     admin_hook, "show current quorum status");
   ceph_assert(r == 0);
-  r = admin_socket->register_command("sync_force name=validate,"
-                                    "type=CephChoices,"
-                                    "strings=--yes-i-really-mean-it",
-                                    admin_hook,
-                                    "force sync of and clear monitor store");
+  r = admin_socket->register_command(
+    "sync_force "
+    //"name=yes_i_really_mean_it,type=CephBool,req=false",
+    "name=validate,type=CephChoices,strings=--yes-i-really-mean-it,req=false",
+    admin_hook,
+    "force sync of and clear monitor store");
   ceph_assert(r == 0);
   r = admin_socket->register_command("add_bootstrap_peer_hint name=addr,"
                                     "type=CephIPAddr",
@@ -2487,16 +2489,8 @@ void Monitor::get_combined_feature_map(FeatureMap *fm)
   }
 }
 
-void Monitor::sync_force(Formatter *f, ostream& ss)
+void Monitor::sync_force(Formatter *f)
 {
-  bool free_formatter = false;
-
-  if (!f) {
-    // louzy/lazy hack: default to json if no formatter has been defined
-    f = new JSONFormatter();
-    free_formatter = true;
-  }
-
   auto tx(std::make_shared<MonitorDBStore::Transaction>());
   sync_stash_critical_state(tx);
   tx->put("mon_sync", "force_sync", 1);
@@ -2506,9 +2500,6 @@ void Monitor::sync_force(Formatter *f, ostream& ss)
   f->dump_int("ret", 0);
   f->dump_stream("msg") << "forcing store sync the next time the monitor starts";
   f->close_section(); // sync_force
-  f->flush(ss);
-  if (free_formatter)
-    delete f;
 }
 
 void Monitor::_quorum_status(Formatter *f, ostream& ss)
@@ -3373,11 +3364,9 @@ void Monitor::handle_command(MonOpRequestRef op)
       /* Let the Monitor class handle the following commands:
        *  'mon compact'
        *  'mon scrub'
-       *  'mon sync force'
        */
       prefix != "mon compact" &&
       prefix != "mon scrub" &&
-      prefix != "mon sync force" &&
       prefix != "mon metadata" &&
       prefix != "mon versions" &&
       prefix != "mon count-metadata" &&
@@ -3744,23 +3733,6 @@ void Monitor::handle_command(MonOpRequestRef op)
     }
     r = 0;
     rs = "safe to remove mon." + id;
-  } else if (prefix == "sync force" ||
-             prefix == "mon sync force") {
-    bool validate1 = false;
-    cmd_getval(g_ceph_context, cmdmap, "yes_i_really_mean_it", validate1);
-    bool validate2 = false;
-    cmd_getval(g_ceph_context, cmdmap, "i_know_what_i_am_doing", validate2);
-
-    if (!validate1 || !validate2) {
-      r = -EINVAL;
-      rs = "are you SURE? this will mean the monitor store will be "
-          "erased.  pass '--yes-i-really-mean-it "
-          "--i-know-what-i-am-doing' if you really do.";
-      goto out;
-    }
-    sync_force(f.get(), ds);
-    rs = ds.str();
-    r = 0;
   } else if (prefix == "heap") {
     if (!ceph_using_tcmalloc())
       rs = "tcmalloc not enabled, can't use heap profiler commands\n";
index 294fbe3b7e6504a01b04bed034f723de28f680c9..c9522334e0fda7ff8d7369d92cacd26a342438dc 100644 (file)
@@ -397,7 +397,7 @@ public:
   /**
    * force a sync on next mon restart
    */
-  void sync_force(Formatter *f, ostream& ss);
+  void sync_force(Formatter *f);
 
 private:
   /**