From: Sage Weil Date: Fri, 11 Oct 2019 00:08:50 +0000 (-0500) Subject: mon: consolidate 'sync force' commands X-Git-Tag: v15.1.0~1178^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e3260a81d5f82b22ef050b68412d3e79d3a7e2ec;p=ceph.git mon: consolidate 'sync force' commands 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 --- diff --git a/PendingReleaseNotes b/PendingReleaseNotes index 974796806b3e..1df7e0c2d6a1 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -111,6 +111,9 @@ 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 diff --git a/doc/man/8/ceph.rst b/doc/man/8/ceph.rst index 455a350fe332..beaa008cf553 100644 --- a/doc/man/8/ceph.rst +++ b/doc/man/8/ceph.rst @@ -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 ---- diff --git a/qa/tasks/mon_thrash.py b/qa/tasks/mon_thrash.py index ed0940c4ebf2..67ee6f714098 100644 --- a/qa/tasks/mon_thrash.py +++ b/qa/tasks/mon_thrash.py @@ -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( diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index ca6915615af5..9aa31a24a1a1 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -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' } diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index 7e222892783a..850a54e855fb 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -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(); diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index af63793659ec..e14c9fefbfae 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -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 ", "mon", "r") diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index a4f6def716ca..aa1f9b95ffcb 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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()); 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"; diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 294fbe3b7e65..c9522334e0fd 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -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: /**