From: Sage Weil Date: Sun, 7 Apr 2019 18:54:59 +0000 (-0500) Subject: common: add --log-early command line option X-Git-Tag: v14.2.1~55^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F27388%2Fhead;p=ceph.git common: add --log-early command line option Sometime it is important and useful to see the logs from the bootstrap phase where we are getting the initial configs from the monitors. Add a command-line option --log-early to do that. Signed-off-by: Sage Weil (cherry picked from commit 933d5084cb66f299a7bf60f0a2a6382c0bd3cb2f) --- diff --git a/src/common/config.cc b/src/common/config.cc index a51f075c837f..b6feaba4b1f1 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -572,6 +572,9 @@ int md_config_t::parse_argv(ConfigValues& values, else if (ceph_argparse_flag(args, i, "--no-mon-config", (char*)NULL)) { values.no_mon_config = true; } + else if (ceph_argparse_flag(args, i, "--log-early", (char*)NULL)) { + values.log_early = true; + } else if (ceph_argparse_flag(args, i, "--mon-config", (char*)NULL)) { values.no_mon_config = false; } diff --git a/src/common/config_values.h b/src/common/config_values.h index fdfff2b16f33..ab52060e4629 100644 --- a/src/common/config_values.h +++ b/src/common/config_values.h @@ -28,6 +28,7 @@ public: string cluster; ceph::logging::SubsystemMap subsys; bool no_mon_config = false; + bool log_early = false; // Set of configuration options that have changed since the last // apply_changes using changed_set_t = std::set; diff --git a/src/global/global_init.cc b/src/global/global_init.cc index abce4c05529b..eb8bbfd1a4db 100644 --- a/src/global/global_init.cc +++ b/src/global/global_init.cc @@ -142,6 +142,11 @@ void global_pre_init( // command line (as passed by caller) conf.parse_argv(args); + if (conf->log_early && + !cct->_log->is_started()) { + cct->_log->start(); + } + if (!conf->no_mon_config) { // make sure our mini-session gets legacy values conf.apply_changes(nullptr); @@ -154,7 +159,10 @@ void global_pre_init( _exit(1); } } - cct->_log->start(); + if (!cct->_log->is_started()) { + cct->_log->start(); + } + // do the --show-config[-val], if present in argv conf.do_argv_commands(); diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 6f75b2fff74e..0f23fa8e120a 100755 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -79,6 +79,11 @@ public: { int ret; + if (cct->_conf->log_early && + !cct->_log->is_started()) { + cct->_log->start(); + } + { MonClient mc_bootstrap(cct); ret = mc_bootstrap.get_monmap_and_config(); diff --git a/src/librados/RadosClient.cc b/src/librados/RadosClient.cc index 446482e1af23..e23217599877 100644 --- a/src/librados/RadosClient.cc +++ b/src/librados/RadosClient.cc @@ -238,6 +238,11 @@ int librados::RadosClient::connect() return -EISCONN; state = CONNECTING; + if (cct->_conf->log_early && + !cct->_log->is_started()) { + cct->_log->start(); + } + { MonClient mc_bootstrap(cct); err = mc_bootstrap.get_monmap_and_config();