From 339ef6a306802b0f712464beeaae57329140d15f Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 16 Jul 2019 11:34:23 +0800 Subject: [PATCH] tools/ceph_conf: s/global_pre_init/global_init/ we switched over from `global_init()` to `global_pre_init()` in fc1a424e837bee139726eec333c9efd65e2abb6a to address http://tracker.ceph.com/issues/7849 . but this change prevents us from moving the `mc_bootstrap.get_monmap_and_config()` call from `global_pre_init()` to `global_init()`, as the call utilizes the transport layer. see https://tracker.ceph.com/issues/39238. so it'd better to avoid accessing a previously opened fd after credentials change. in this change, * a default "log_to_file"="false" setting is passed to `global_init()` to disable the logging subsystem from creating a log file. * use a lambda for initializing `cct`, so no need to have a copy of the original args * remove `apply_changes()` and `complain_about_parse_error()` calls, as they are already taken care of by `global_init()`. Signed-off-by: Kefu Chai (cherry picked from commit 031ddc34b1d0a74765de22280e4e3cdb37765405) Conflicts: src/tools/ceph_conf.cc: Trivial function name change --- src/tools/ceph_conf.cc | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/tools/ceph_conf.cc b/src/tools/ceph_conf.cc index d7d341481ce3a..fb046f8eeb2b8 100644 --- a/src/tools/ceph_conf.cc +++ b/src/tools/ceph_conf.cc @@ -174,19 +174,14 @@ int main(int argc, const char **argv) std::string dump_format; argv_to_vec(argc, argv, args); - vector orig_args = args; - - global_pre_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON, - CINIT_FLAG_NO_DAEMON_ACTIONS | - CINIT_FLAG_NO_MON_CONFIG); - std::unique_ptr > cct_deleter{ - g_ceph_context, - [](CephContext *p) {p->put();} - }; - - g_conf().apply_changes(nullptr); - g_conf().complain_about_parse_errors(g_ceph_context); + auto orig_args = args; + auto cct = [&args] { + std::map defaults = {{"log_to_file", "false"}}; + return global_init(&defaults, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_DAEMON, + CINIT_FLAG_NO_DAEMON_ACTIONS | + CINIT_FLAG_NO_MON_CONFIG); + }(); // do not common_init_finish(); do not start threads; do not do any of thing // wonky things the daemon whose conf we are examining would do (like initialize @@ -245,7 +240,7 @@ int main(int argc, const char **argv) } } - g_ceph_context->_log->flush(); + cct->_log->flush(); if (action == "help") { usage(); exit(0); -- 2.39.5