From 933d5084cb66f299a7bf60f0a2a6382c0bd3cb2f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 7 Apr 2019 13:54:59 -0500 Subject: [PATCH] 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 --- src/common/config.cc | 3 +++ src/common/config_values.h | 1 + src/global/global_init.cc | 10 +++++++++- src/libcephfs.cc | 5 +++++ src/librados/RadosClient.cc | 5 +++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/common/config.cc b/src/common/config.cc index d1895a21c0b73..48b71dad1e2c9 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -570,6 +570,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 51f7923533290..de1661ad10b82 100644 --- a/src/common/config_values.h +++ b/src/common/config_values.h @@ -28,6 +28,7 @@ public: std::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 abce4c05529b8..eb8bbfd1a4dbb 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 6f75b2fff74e2..0f23fa8e120a8 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 446482e1af231..e232175998779 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(); -- 2.47.3