]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/ceph_conf: s/global_pre_init/global_init/
authorKefu Chai <kchai@redhat.com>
Tue, 16 Jul 2019 03:34:23 +0000 (11:34 +0800)
committerBrad Hubbard <bhubbard@redhat.com>
Mon, 14 Dec 2020 02:07:04 +0000 (12:07 +1000)
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 <kchai@redhat.com>
(cherry picked from commit 031ddc34b1d0a74765de22280e4e3cdb37765405)

 Conflicts:
src/tools/ceph_conf.cc: Trivial function name change

src/tools/ceph_conf.cc

index d7d341481ce3af860033b4dffc73394ea9386379..fb046f8eeb2b8946a5e32de5a88f688f318bdcf8 100644 (file)
@@ -174,19 +174,14 @@ int main(int argc, const char **argv)
   std::string dump_format;
 
   argv_to_vec(argc, argv, args);
-  vector<const char*> 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<CephContext,
-                 std::function<void(CephContext*)> > 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<std::string,std::string> 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);