}
int md_config_t::parse_config_files(const char *conf_files,
- std::deque<std::string> *parse_errors,
std::ostream *warnings,
int flags)
{
}
std::list<std::string> cfl;
get_str_list(conf_files, cfl);
- return parse_config_files_impl(cfl, parse_errors, warnings);
+ return parse_config_files_impl(cfl, warnings);
}
int md_config_t::parse_config_files_impl(const std::list<std::string> &conf_files,
- std::deque<std::string> *parse_errors,
std::ostream *warnings)
{
assert(lock.is_locked());
cf.clear();
string fn = *c;
expand_meta(fn, warnings);
- int ret = cf.parse_file(fn.c_str(), parse_errors, warnings);
+ int ret = cf.parse_file(fn.c_str(), &parse_errors, warnings);
if (ret == 0)
break;
else if (ret != -ENOENT)
}
if (!old_style_section_names.empty()) {
ostringstream oss;
- oss << "ERROR! old-style section name(s) found: ";
+ cerr << "ERROR! old-style section name(s) found: ";
string sep;
for (std::deque < std::string >::const_iterator os = old_style_section_names.begin();
os != old_style_section_names.end(); ++os) {
- oss << sep << *os;
+ cerr << sep << *os;
sep = ", ";
}
- oss << ". Please use the new style section names that include a period.";
- parse_errors->push_back(oss.str());
+ cerr << ". Please use the new style section names that include a period.";
}
return 0;
}
diff->insert(make_pair(opt->name, make_pair(local_val, other_val)));
}
}
+
+void md_config_t::complain_about_parse_errors(CephContext *cct)
+{
+ ::complain_about_parse_errors(cct, &parse_errors);
+}
// Parse a config file
int parse_config_files(const char *conf_files,
- std::deque<std::string> *parse_errors,
std::ostream *warnings, int flags);
// Absorb config settings from the environment
void diff(const md_config_t *other,
map<string,pair<string,string> > *diff, set<string> *unknown);
+ /// print/log warnings/errors from parsing the config
+ void complain_about_parse_errors(CephContext *cct);
+
private:
void _show_config(std::ostream *out, Formatter *f);
int parse_injectargs(std::vector<const char*>& args,
std::ostream *oss);
int parse_config_files_impl(const std::list<std::string> &conf_files,
- std::deque<std::string> *parse_errors,
std::ostream *warnings);
int set_val_impl(const char *val, const config_option *opt);
// The configuration file we read, or NULL if we haven't read one.
ConfFile cf;
+public:
+ std::deque<std::string> parse_errors;
+private:
obs_map_t observers;
changed_set_t changed;
if (alt_def_args)
conf->parse_argv(*alt_def_args); // alternative default args
- std::deque<std::string> parse_errors;
- int ret = conf->parse_config_files(c_str_or_null(conf_file_list), &parse_errors, &cerr, flags);
+ int ret = conf->parse_config_files(c_str_or_null(conf_file_list),
+ &cerr, flags);
if (ret == -EDOM) {
dout_emergency("global_init: error parsing config file.\n");
_exit(1);
conf->parse_argv(args); // argv override
// Now we're ready to complain about config file parse errors
- complain_about_parse_errors(cct, &parse_errors);
+ g_conf->complain_about_parse_errors(g_ceph_context);
}
void global_init(std::vector < const char * > *alt_def_args,
int conf_read_file(const char *path_list)
{
- std::deque<std::string> parse_errors;
- int ret = cct->_conf->parse_config_files(path_list, &parse_errors, NULL, 0);
+ int ret = cct->_conf->parse_config_files(path_list, NULL, 0);
if (ret)
return ret;
cct->_conf->apply_changes(NULL);
- complain_about_parse_errors(cct, &parse_errors);
+ cct->_conf->complain_about_parse_errors(cct);
return 0;
}
tracepoint(librados, rados_conf_read_file_enter, cluster, path_list);
librados::RadosClient *client = (librados::RadosClient *)cluster;
md_config_t *conf = client->cct->_conf;
- std::deque<std::string> parse_errors;
- int ret = conf->parse_config_files(path_list, &parse_errors, NULL, 0);
+ int ret = conf->parse_config_files(path_list, NULL, 0);
if (ret) {
tracepoint(librados, rados_conf_read_file_exit, ret);
return ret;
conf->parse_env(); // environment variables override
conf->apply_changes(NULL);
- complain_about_parse_errors(client->cct, &parse_errors);
+ client->cct->_conf->complain_about_parse_errors(client->cct);
tracepoint(librados, rados_conf_read_file_exit, 0);
return 0;
}
TEST(ConfUtils, Overrides) {
md_config_t conf;
- std::deque<std::string> err;
std::ostringstream warn;
std::string override_conf_1_f(next_tempfile(override_config_1));
conf.name.set(CEPH_ENTITY_TYPE_MON, "0");
- conf.parse_config_files(override_conf_1_f.c_str(), &err, &warn, 0);
- ASSERT_EQ(err.size(), 0U);
+ conf.parse_config_files(override_conf_1_f.c_str(), &warn, 0);
+ ASSERT_EQ(conf.parse_errors.size(), 0U);
ASSERT_EQ(conf.log_file, "global_log");
conf.name.set(CEPH_ENTITY_TYPE_MDS, "a");
- conf.parse_config_files(override_conf_1_f.c_str(), &err, &warn, 0);
- ASSERT_EQ(err.size(), 0U);
+ conf.parse_config_files(override_conf_1_f.c_str(), &warn, 0);
+ ASSERT_EQ(conf.parse_errors.size(), 0U);
ASSERT_EQ(conf.log_file, "mds_log");
conf.name.set(CEPH_ENTITY_TYPE_OSD, "0");
- conf.parse_config_files(override_conf_1_f.c_str(), &err, &warn, 0);
- ASSERT_EQ(err.size(), 0U);
+ conf.parse_config_files(override_conf_1_f.c_str(), &warn, 0);
+ ASSERT_EQ(conf.parse_errors.size(), 0U);
ASSERT_EQ(conf.log_file, "osd0_log");
}
TEST(ConfUtils, DupKey) {
md_config_t conf;
- std::deque<std::string> err;
std::ostringstream warn;
std::string dup_key_config_f(next_tempfile(dup_key_config_1));
conf.name.set(CEPH_ENTITY_TYPE_MDS, "a");
- conf.parse_config_files(dup_key_config_f.c_str(), &err, &warn, 0);
- ASSERT_EQ(err.size(), 0U);
+ conf.parse_config_files(dup_key_config_f.c_str(), &warn, 0);
+ ASSERT_EQ(conf.parse_errors.size(), 0U);
ASSERT_EQ(conf.log_file, string("3"));
}
librados::TestRadosClient *client =
reinterpret_cast<librados::TestRadosClient*>(cluster);
md_config_t *conf = client->cct()->_conf;
- std::deque<std::string> parse_errors;
- int ret = conf->parse_config_files(path, &parse_errors, NULL, 0);
+ int ret = conf->parse_config_files(path, NULL, 0);
if (ret == 0) {
conf->parse_env();
conf->apply_changes(NULL);
- complain_about_parse_errors(client->cct(), &parse_errors);
+ conf->complain_about_parse_errors(client->cct());
} else if (ret == -EINVAL) {
// ignore missing client config
return 0;