From ccfb6b3a86ba211b7a7a3c2064ff9488e591c5e1 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Mon, 30 Apr 2012 15:06:17 -0700 Subject: [PATCH] global_init: don't fail out if there is no default config. There are plenty of scenarios where the user doesn't need a config file. Instead, just print a warning and let things move on. Signed-off-by: Greg Farnum --- src/global/global_init.cc | 12 +++++++++--- src/test/cli/ceph-conf/env-vs-args.t | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/global/global_init.cc b/src/global/global_init.cc index 84644a6d91b69..a977fbe2bc184 100644 --- a/src/global/global_init.cc +++ b/src/global/global_init.cc @@ -81,8 +81,12 @@ void global_init(std::vector < const char * > *alt_def_args, std::vector < const } else if (ret == -EINVAL) { if (!(flags & CINIT_FLAG_NO_DEFAULT_CONFIG_FILE)) { - dout_emergency("global_init: unable to open config file.\n"); - _exit(1); + if (conf_file_list.length()) { + dout_emergency("global_init: unable to open config file.\n"); + _exit(1); + } else { + derr <<"did not load config file, using default settings." << dendl; + } } } else if (ret) { @@ -100,7 +104,9 @@ void global_init(std::vector < const char * > *alt_def_args, std::vector < const g_lockdep = cct->_conf->lockdep; // Now we're ready to complain about config file parse errors - complain_about_parse_errors(cct, &parse_errors); + if (conf_file_list.length()) { + complain_about_parse_errors(cct, &parse_errors); + } // signal stuff int siglist[] = { SIGPIPE, 0 }; diff --git a/src/test/cli/ceph-conf/env-vs-args.t b/src/test/cli/ceph-conf/env-vs-args.t index 193e40c2d6099..7eefd98b79343 100644 --- a/src/test/cli/ceph-conf/env-vs-args.t +++ b/src/test/cli/ceph-conf/env-vs-args.t @@ -1,6 +1,6 @@ # we can use CEPH_CONF to override the normal configuration file location. $ env CEPH_CONF=from-env ceph-conf -s foo bar - global_init: unable to open config file. (re) + .* \-1 did not load config file, using default settings. (re) [1] # command-line arguments should override environment -- 2.39.5