From a50c7d3b2f9eaca53a96f7942eaa203a849b3317 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 10 Dec 2012 16:41:19 -0800 Subject: [PATCH] config: do not always print config file missing errors Do not generate errors each time we fail to open a config file; only generate one at the end if a search path was specified and none were usable, right before we (already) exit. This avoids spamming stderr about each path we tried in the search list before we found a good one. Signed-off-by: Sage Weil --- src/common/ConfUtils.cc | 3 --- src/global/global_init.cc | 5 ++++- src/test/cli/ceph-conf/env-vs-args.t | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/ConfUtils.cc b/src/common/ConfUtils.cc index a9e5d7a42f54b..147cdc2fb60a2 100644 --- a/src/common/ConfUtils.cc +++ b/src/common/ConfUtils.cc @@ -101,9 +101,6 @@ parse_file(const std::string &fname, std::deque *errors, FILE *fp = fopen(fname.c_str(), "r"); if (!fp) { ret = -errno; - ostringstream oss; - oss << "read_conf: failed to open '" << fname << "': " << cpp_strerror(ret); - errors->push_back(oss.str()); return ret; } diff --git a/src/global/global_init.cc b/src/global/global_init.cc index 0182fb0ccaaf5..43ce09095651a 100644 --- a/src/global/global_init.cc +++ b/src/global/global_init.cc @@ -82,7 +82,10 @@ 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)) { if (conf_file_list.length()) { - dout_emergency("global_init: unable to open config file.\n"); + ostringstream oss; + oss << "global_init: unable to open config file from search list " + << conf_file_list << "\n"; + dout_emergency(oss.str()); _exit(1); } else { derr <<"did not load config file, using default settings." << dendl; diff --git a/src/test/cli/ceph-conf/env-vs-args.t b/src/test/cli/ceph-conf/env-vs-args.t index 7eefd98b79343..76b2dec9cfb85 100644 --- a/src/test/cli/ceph-conf/env-vs-args.t +++ b/src/test/cli/ceph-conf/env-vs-args.t @@ -5,6 +5,6 @@ # command-line arguments should override environment $ env -u CEPH_CONF ceph-conf -c from-args - global_init: unable to open config file. (re) + global_init: unable to open config file from search list from-args [1] -- 2.39.5