diff options
author | Sage Weil <sage@inktank.com> | 2013-06-19 16:27:34 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-06-19 19:44:45 -0700 |
commit | 716fc3501ac6655c47e86fbb31d57e5afd8d0240 (patch) | |
tree | f64ccd45cd47e30c9b042e0f0af7875f21f8892c | |
parent | 2a4953b697a3464862fd3913336edfd7eede2487 (diff) | |
download | ceph-716fc3501ac6655c47e86fbb31d57e5afd8d0240.tar.gz |
ceph-conf: make --show-config-value reflect daemon defaults
We want DAEMON defaults, but we don't want global_init to do anything else
daemonish like print a banner or mkdir /var/run/ceph. This lets us use
ceph-conf -n osd.0 --show-config-value log_file
to get the default, while
ceph-conf -n osd.0 log_file
only reflects what is in the config file.
Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r-- | src/ceph_conf.cc | 4 | ||||
-rw-r--r-- | src/common/common_init.h | 3 | ||||
-rw-r--r-- | src/global/global_init.cc | 5 | ||||
-rw-r--r-- | src/test/cli/ceph-conf/show-config-value.t | 5 |
4 files changed, 14 insertions, 3 deletions
diff --git a/src/ceph_conf.cc b/src/ceph_conf.cc index 608c0852122..b2286f4e094 100644 --- a/src/ceph_conf.cc +++ b/src/ceph_conf.cc @@ -156,7 +156,9 @@ int main(int argc, const char **argv) argv_to_vec(argc, argv, args); env_to_vec(args); - global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0); + + global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON, + CINIT_FLAG_NO_DAEMON_ACTIONS); // 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 diff --git a/src/common/common_init.h b/src/common/common_init.h index 3dfd12915f4..f48b349bf00 100644 --- a/src/common/common_init.h +++ b/src/common/common_init.h @@ -34,6 +34,9 @@ enum common_init_flags_t { // Don't close stderr (in daemonize) CINIT_FLAG_NO_CLOSE_STDERR = 0x4, + + // don't do anything daemonish, like create /var/run/ceph, or print a banner + CINIT_FLAG_NO_DAEMON_ACTIONS = 0x8, }; /* diff --git a/src/global/global_init.cc b/src/global/global_init.cc index 8363d0e191a..e96c317f820 100644 --- a/src/global/global_init.cc +++ b/src/global/global_init.cc @@ -120,7 +120,8 @@ void global_init(std::vector < const char * > *alt_def_args, std::vector < const g_ceph_context->_log->set_flush_on_exit(); if (g_conf->run_dir.length() && - code_env == CODE_ENVIRONMENT_DAEMON) { + code_env == CODE_ENVIRONMENT_DAEMON && + !(flags & CINIT_FLAG_NO_DAEMON_ACTIONS)) { int r = ::mkdir(g_conf->run_dir.c_str(), 0755); if (r < 0 && errno != EEXIST) { r = -errno; @@ -138,7 +139,7 @@ void global_init(std::vector < const char * > *alt_def_args, std::vector < const // and opening the log file immediately. conf->call_all_observers(); - if (code_env == CODE_ENVIRONMENT_DAEMON) + if (code_env == CODE_ENVIRONMENT_DAEMON && !(flags & CINIT_FLAG_NO_DAEMON_ACTIONS)) output_ceph_version(); } diff --git a/src/test/cli/ceph-conf/show-config-value.t b/src/test/cli/ceph-conf/show-config-value.t new file mode 100644 index 00000000000..03d7ed8e086 --- /dev/null +++ b/src/test/cli/ceph-conf/show-config-value.t @@ -0,0 +1,5 @@ + +# should reflect daemon defaults + + $ ceph-conf -n osd.0 --show-config-value log_file -c /dev/null + /var/log/ceph/ceph-osd.0.log |