}
#endif // #ifndef WITH_SEASTAR
-void complain_about_parse_errors(CephContext *cct,
- std::deque<std::string> *parse_errors)
+void complain_about_parse_error(CephContext *cct,
+ const string& parse_error)
{
- if (parse_errors->empty())
+ if (parse_error.empty())
return;
lderr(cct) << "Errors while parsing config file!" << dendl;
- int cur_err = 0;
- static const int MAX_PARSE_ERRORS = 20;
- for (std::deque<std::string>::const_iterator p = parse_errors->begin();
- p != parse_errors->end(); ++p)
- {
- lderr(cct) << *p << dendl;
- if (cur_err == MAX_PARSE_ERRORS) {
- lderr(cct) << "Suppressed " << (parse_errors->size() - MAX_PARSE_ERRORS)
- << " more errors." << dendl;
- break;
- }
- ++cur_err;
- }
+ lderr(cct) << parse_error << dendl;
}
#ifndef WITH_SEASTAR
enum code_environment_t code_env, int flags);
#endif // #ifndef WITH_SEASTAR
-/* Print out some parse errors. */
-void complain_about_parse_errors(CephContext *cct,
- std::deque<std::string> *parse_errors);
+/* Print out some parse error. */
+void complain_about_parse_error(CephContext *cct,
+ const std::string& parse_error);
/* This function is called after you have done your last
* fork. When you make this call, the system will initialize everything that
for (c = conf_files.begin(); c != conf_files.end(); ++c) {
cf.clear();
string fn = *c;
-
ostringstream oss;
int ret = cf.parse_file(fn.c_str(), &oss);
- if (ret == 0)
+ parse_error = oss.str();
+ if (ret == 0) {
break;
- if (ret) {
- parse_errors.push_back(oss.str());
}
if (ret != -ENOENT)
return ret;
});
}
-void md_config_t::complain_about_parse_errors(CephContext *cct)
+void md_config_t::complain_about_parse_error(CephContext *cct)
{
- ::complain_about_parse_errors(cct, &parse_errors);
+ ::complain_about_parse_error(cct, parse_error);
}
std::string name = {}) const;
/// print/log warnings/errors from parsing the config
- void complain_about_parse_errors(CephContext *cct);
+ void complain_about_parse_error(CephContext *cct);
private:
// we use this to avoid variable expansion loops
// The configuration file we read, or NULL if we haven't read one.
ConfFile cf;
public:
- std::deque<std::string> parse_errors;
+ std::string parse_error;
private:
// This will be set to true when it is safe to start threads.
return config.parse_config_files(values, obs_mgr,
conf_files, warnings, flags);
}
- size_t num_parse_errors() const {
- return config.parse_errors.size();
+ bool has_parse_error() const {
+ return !config.parse_error.empty();
}
- void complain_about_parse_errors(CephContext *cct) {
- return config.complain_about_parse_errors(cct);
+ void complain_about_parse_error(CephContext *cct) {
+ return config.complain_about_parse_error(cct);
}
void do_argv_commands() const {
std::lock_guard l{lock};
conf.do_argv_commands();
// Now we're ready to complain about config file parse errors
- g_conf().complain_about_parse_errors(g_ceph_context);
+ g_conf().complain_about_parse_error(g_ceph_context);
}
boost::intrusive_ptr<CephContext>
}
// Now we're ready to complain about config file parse errors
- g_conf().complain_about_parse_errors(g_ceph_context);
+ g_conf().complain_about_parse_error(g_ceph_context);
// test leak checking
if (g_conf()->debug_deliberately_leak_memory) {
if (ret)
return ret;
cct->_conf.apply_changes(nullptr);
- cct->_conf.complain_about_parse_errors(cct);
+ cct->_conf.complain_about_parse_error(cct);
return 0;
}
if (ret) {
if (warnings.tellp() > 0)
lderr(client->cct) << warnings.str() << dendl;
- client->cct->_conf.complain_about_parse_errors(client->cct);
+ client->cct->_conf.complain_about_parse_error(client->cct);
tracepoint(librados, rados_conf_read_file_exit, ret);
return ret;
}
conf.parse_env(client->cct->get_module_type()); // environment variables override
conf.apply_changes(nullptr);
- client->cct->_conf.complain_about_parse_errors(client->cct);
+ client->cct->_conf.complain_about_parse_error(client->cct);
tracepoint(librados, rados_conf_read_file_exit, 0);
return 0;
}
conf->name.set(CEPH_ENTITY_TYPE_MON, "0");
conf.parse_config_files(override_conf_1_f.c_str(), &warn, 0);
- ASSERT_EQ(conf.num_parse_errors(), 0U);
+ ASSERT_FALSE(conf.has_parse_error());
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(), &warn, 0);
- ASSERT_EQ(conf.num_parse_errors(), 0U);
+ ASSERT_FALSE(conf.has_parse_error());
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(), &warn, 0);
- ASSERT_EQ(conf.num_parse_errors(), 0U);
+ ASSERT_FALSE(conf.has_parse_error());
ASSERT_EQ(conf->log_file, "osd0_log");
}
conf->name.set(CEPH_ENTITY_TYPE_MDS, "a");
conf.parse_config_files(dup_key_config_f.c_str(), &warn, 0);
- ASSERT_EQ(conf.num_parse_errors(), 0U);
+ ASSERT_FALSE(conf.has_parse_error());
ASSERT_EQ(conf->log_file, string("3"));
}
if (ret == 0) {
conf.parse_env(client->cct()->get_module_type());
conf.apply_changes(NULL);
- conf.complain_about_parse_errors(client->cct());
+ conf.complain_about_parse_error(client->cct());
} else if (ret == -ENOENT) {
// ignore missing client config
return 0;
};
g_conf().apply_changes(nullptr);
- g_conf().complain_about_parse_errors(g_ceph_context);
+ g_conf().complain_about_parse_error(g_ceph_context);
// 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
// disable unnecessary librbd cache
cct->_conf.set_val_or_die("rbd_cache", "false");
cct->_conf.apply_changes(nullptr);
- cct->_conf.complain_about_parse_errors(cct);
+ cct->_conf.complain_about_parse_error(cct);
r = (*rados_ref)->init_with_context(cct);
ceph_assert(r == 0);