Repository navigation
mon,mgr: improve 'mgr module disable' cmd - #21188
Conversation
|
b1bfe39 to
8d8943d
Compare
There was a problem hiding this comment.
Just wondering: would it make sense to rename this to module_enabled or is_enabled?
There was a problem hiding this comment.
This is not desired behaviour -- all Ceph CLI operations should be idempotent, so disabling a disabled module should return 0.
There was a problem hiding this comment.
I would agree that disabling a nonexistent module should be an error (in order to detect mistyped module names), but I don't think all_support_module is the right check. We should accept a disable command if any mgr has reported the module.
There was a problem hiding this comment.
@jcsp , I re-checked the all_support_module(), it seems it included all mgrs' reported modules(both active and standby). Could you point out why it is not the right check?
There was a problem hiding this comment.
If module foo is enabled, and module foo is installed on mgr.x, but not mgr.y, then all_support_module would return false and we would return -ENOENT. The correct behaviour in that case would be to proceed with successfully disabling the module, even if some mgr daemons do not have it.
There was a problem hiding this comment.
@jcsp got it. I updated the fix, please take a look.
There was a problem hiding this comment.
Same as in the disable case, if the module is already enabled then we must return 0 to be idempotent.
091cef2 to
f325b1a
Compare
There was a problem hiding this comment.
I suggest naming this function any_support_module so that its relationship with all_support_module is more obvious
There was a problem hiding this comment.
Since modules is a std::set, you can make this function a one-liner modules.find(module_name) != modules.end()
f325b1a to
b0c3120
Compare
There was a problem hiding this comment.
this breaks the test of test_mon_misc() in qa/workunits/cephtool/test.sh, see http://pulpito.ceph.com/kchai-2018-04-13_07:54:02-rados-wip-kefu-testing-2018-04-13-1431-distro-basic-smithi/2394008/
2018-04-13T08:13:18.738 INFO:tasks.workunit.client.0.smithi109.stderr:/home/ubuntu/cephtest/clone.client.0/qa/workunits/cephtool/test.sh:751: test_mon_misc: ceph mgr module disable foodne
2018-04-13T08:13:19.020 INFO:tasks.workunit.client.0.smithi109.stderr:Error ENOENT: module foodne does not exist
probably we could just drop this check?
There was a problem hiding this comment.
I think we should move the check inside the !pending_map.module_enabled block, so that the test can still disable a non-existent module if the module was enabled with --force at some point.
Then the test should also be updated on the foodnebizbangbash line to expect that to fail.
There was a problem hiding this comment.
@jcsp how about set the retval =0, if pending_map.any_support_module(module) is false?
There was a problem hiding this comment.
Actually what I just suggested was wrong because it wouldn't be idempotent. We need to return 0 from all these cases.
However, in the !pending_map.any_support_module(module) we can't just return, because it might still need removing from the list of enabled modules if it was added with --force. We can do that by moving this block after the !pending_map.module_enabled(module) one, and just set the ss output rather then returning.
So I think the correct code would be:
if (!pending_map.module_enabled(module)) {
ss << "module " << module << " is already disabled";
r = 0;
goto out;
}
if (!pending_map.any_support_module(module)) {
ss << "module " << module << " does not exist";
}
pending_map.modules.erase(module);
b0c3120 to
2ae847e
Compare
tchaikov
left a comment
There was a problem hiding this comment.
also, could you squash these two commits into a single one?
There was a problem hiding this comment.
please be consistent where to put the &. i'd suggest put it right next to std::string.
There was a problem hiding this comment.
nit, remove the parentheses around this statement.
There was a problem hiding this comment.
mark this method const, if you please.
There was a problem hiding this comment.
"any" is singular, so should be "supports", i guess?
There was a problem hiding this comment.
Either way is probably fine. I had been reading this as a contraction of "[do] any [daemons] support module" rather than "[if] any [daemon] supports module". I don't even know the right grammar terminology to describe the difference though :-D
There was a problem hiding this comment.
i'd suggest add quotes around "module", like
ss << "module '" << module << "' is already disabled";|
retest this please (jenkins) |
2ae847e to
1cabf79
Compare
|
@tchaikov all your comments are addressed. please take a look. |
|
@guzhongyan needs rebase |
when running those cmds, check if the module do exist or is disabled already. also check if the module is enabled already. Signed-off-by: Gu Zhongyan <[email protected]>
1cabf79 to
a7677c7
Compare
|
@tchaikov rebased, Thanks. |
|
test failures are tracked / addressed by |
check if the module do exist or is disabled already.
Signed-off-by: Gu Zhongyan [email protected]