Skip to content

Commit

Permalink
honor CINIT_FLAG_NO_DEFAULT_CONFIG_FILE
Browse files Browse the repository at this point in the history
Don't use CEPH_CONF_FILE_DEFAULT when CINIT_FLAG_NO_DEFAULT_CONFIG_FILE
is set.

Signed-off-by: Colin McCabe <[email protected]>
  • Loading branch information
cmccabe committed Jul 5, 2011
1 parent 5b2de2b commit 1da8f81
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
11 changes: 9 additions & 2 deletions src/common/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,18 @@ remove_observer(md_config_obs_t* observer_)

int md_config_t::
parse_config_files(const char *conf_files,
std::deque<std::string> *parse_errors)
std::deque<std::string> *parse_errors, int flags)
{
if (!conf_files) {
const char *c = getenv("CEPH_CONF");
conf_files = c ? c : CEPH_CONF_FILE_DEFAULT;
if (c) {
conf_files = c;
}
else {
if (flags & CINIT_FLAG_NO_DEFAULT_CONFIG_FILE)
return 0;
conf_files = CEPH_CONF_FILE_DEFAULT;
}
}
std::list<std::string> cfl;
get_str_list(conf_files, cfl);
Expand Down
2 changes: 1 addition & 1 deletion src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class md_config_t {

// Parse a config file
int parse_config_files(const char *conf_files,
std::deque<std::string> *parse_errors);
std::deque<std::string> *parse_errors, int flags);

// Absorb config settings from the environment
void parse_env();
Expand Down
2 changes: 1 addition & 1 deletion src/global/global_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void global_init(std::vector < const char* >& args,
md_config_t *conf = cct->_conf;

std::deque<std::string> parse_errors;
int ret = conf->parse_config_files(c_str_or_null(conf_file_list), &parse_errors);
int ret = conf->parse_config_files(c_str_or_null(conf_file_list), &parse_errors, flags);
if (ret == -EDOM) {
dout_emergency("global_init: error parsing config file.\n");
_exit(1);
Expand Down
2 changes: 1 addition & 1 deletion src/libceph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class ceph_mount_info
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);
int ret = cct->_conf->parse_config_files(path_list, &parse_errors, 0);
if (ret)
return ret;
cct->_conf->apply_changes();
Expand Down
2 changes: 1 addition & 1 deletion src/librados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3213,7 +3213,7 @@ extern "C" int rados_conf_read_file(rados_t cluster, const char *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);
int ret = conf->parse_config_files(path_list, &parse_errors, 0);
if (ret)
return ret;
conf->parse_env(); // environment variables override
Expand Down
6 changes: 3 additions & 3 deletions src/test/confutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -464,17 +464,17 @@ TEST(Overrides, ConfUtils) {
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);
conf.parse_config_files(override_conf_1_f.c_str(), &err, 0);
ASSERT_EQ(err.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);
conf.parse_config_files(override_conf_1_f.c_str(), &err, 0);
ASSERT_EQ(err.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);
conf.parse_config_files(override_conf_1_f.c_str(), &err, 0);
ASSERT_EQ(err.size(), 0U);
ASSERT_EQ(conf.log_file, "osd0_log");
}

0 comments on commit 1da8f81

Please sign in to comment.