Merge pull request #22395 from liewegas/wip-24408

osd,mds: make 'config rm ...' idempotent

Reviewed-by: Erwan Velu <erwan@redhat.com>
This commit is contained in:
Kefu Chai 2018-06-06 00:03:43 +08:00 committed by GitHub
commit 3270f26672
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 1 deletions

View File

@ -74,6 +74,7 @@ do
done
ceph config show osd.0 | grep debug_xio | grep 'override mon'
ceph tell osd.0 config unset debug_xio
ceph tell osd.0 config unset debug_xio
ceph config rm osd.0 debug_xio
while ceph config show osd.0 | grep debug_xio | grep mon

View File

@ -441,7 +441,7 @@ void CephContext::do_command(std::string_view command, const cmdmap_t& cmdmap,
f->dump_string("error", "syntax error: 'config unset <var>'");
} else {
int r = _conf->rm_val(var.c_str());
if (r < 0) {
if (r < 0 && r != -ENOENT) {
f->dump_stream("error") << "error unsetting '" << var << "': "
<< cpp_strerror(r);
} else {

View File

@ -1413,6 +1413,9 @@ void md_config_t::_refresh(const Option& opt)
int md_config_t::_rm_val(const std::string& key, int level)
{
if (schema.count(key) == 0) {
return -EINVAL;
}
auto i = values.find(key);
if (i == values.end()) {
return -ENOENT;

View File

@ -794,6 +794,9 @@ int MDSDaemon::_handle_command(
if (r == 0) {
cct->_conf->apply_changes(nullptr);
}
if (r == -ENOENT) {
r = 0; // idempotent
}
} else if (prefix == "exit") {
// We will send response before executing
ss << "Exiting...";

View File

@ -5828,6 +5828,9 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector<string>& cmd, buffe
if (r == 0) {
cct->_conf->apply_changes(nullptr);
}
if (r == -ENOENT) {
r = 0; // make command idempotent
}
osd_lock.Lock();
}
else if (prefix == "cluster_log") {