New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config: expand tilde for ~/.ceph/$cluster.conf #20774
Conversation
I would very much not do this in application code. The fact that it is somewhere in the CEPH config is IMHO a problem in itself. And even then the way it is now implemented is that EVERY |
Why do you think it is about ceph config? It is not about tilde somewhere in ceph config. It is with the fact that
No. My code specifically looks if tilde is at the zeroth index of the given string [1] https://github.com/ceph/ceph/blob/master/src/common/config.cc#L45 |
Well my argument is that is should not have been used in this format to begin with, and the PR should be to remove
And if anything like this was required, replace it by $home/.ceph/$cluster.conf. |
src/common/config.cc
Outdated
@@ -248,6 +248,9 @@ int md_config_t::parse_config_files(const char *conf_files, | |||
} else { | |||
cfl.erase(p++); // ignore this item | |||
} | |||
} else if (s.find("~") == 0) { | |||
s.replace(s.find("~"), 1, string(getenv("HOME"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could replace s.replace(s.find("~"), 1, string(getenv("HOME")));
by s.replace(0, 1, string(getenv("HOME")));
b370fdd
to
26424b7
Compare
src/common/config.cc
Outdated
@@ -248,6 +248,9 @@ int md_config_t::parse_config_files(const char *conf_files, | |||
} else { | |||
cfl.erase(p++); // ignore this item | |||
} | |||
} else if (s.find("$home") != string::npos) { | |||
s.replace(0, 5, string(getenv("HOME"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be more appropriate to move this part to somewhere in expand_meta()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rishabh-d-dave
I think that would make sense, it would then be more universially applicable.
9a1f7e1
to
697959c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me (I have no opinion on $home vs ~)
retest this please |
@wjwithagen, @liewegas I don't why make check failed. Locally, it's passing for me - |
@rishabh-d-dave Fixing bug like this, where Jenkins does something different are not easy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise Error('error executing ceph-conf', e, err)
if ret == 1:
# config entry not found
return None
elif ret != 0:
> raise Error('getting variable from configuration failed')
E Error: Error: getting variable from configuration failed
in run-tox-ceph-disk
retest this please. |
|
697959c
to
4006afe
Compare
Before ceph-conf runs this time, the chosen ceph conf file would be displayed and it would be checked if it exists. WRT to how Jenkins runs the test, I'm not sure if the debugging code would really help.
What's DNM? |
@rishabh-d-dave "DNM" stands for "do not merge". @wjwithagen suggested to add this label to your PR so we don't merge it by accident. |
retest this please |
@wjwithagen @tchaikov From the output of the debug code, ~/.ceph/ceph.conf was never chosen from CEPH_CONF_FILE_DEFAULT. IMO, this must mean that the errors are not due to the changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please drop the debug commit and rebase. When I test the first commit only locally it looks ok
src/common/config.cc
Outdated
@@ -1156,6 +1169,8 @@ Option::value_t md_config_t::_expand_meta( | |||
out += stringify(getpid()); | |||
} else if (var == "cctid") { | |||
out += stringify((unsigned long long)this); | |||
} else if (var == "home") { | |||
out = string(getenv("HOME")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small issue: getenv() can return NULL, and std:;string crashes when passed null. Change to
const char *home = getenv("HOME");
out = home ? std::string(home) : std::string();
or similar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
And expand "$home" to get the actual path to ceph.conf. Fixes: http://tracker.ceph.com/issues/23215 Signed-off-by: Rishabh Dave <ridave@redhat.com>
4006afe
to
3b46884
Compare
Fixes: http://tracker.ceph.com/issues/23215
Signed-off-by: Rishabh Dave ridave@redhat.com