mgr/mgr_module.py: CLICommand: Fix parsing of kwargs arguments#36877
Conversation
Make parsing of keyword arguments a bit safer by makeing sure the key is actually a valid parameter name Fixes: https://tracker.ceph.com/issues/47185 Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
jan--f
left a comment
There was a problem hiding this comment.
One behaviour that this patch removes and needs to be re-added is that once a kwarg has been seen, all arguments after the inital must me considered kwargs too. Otherwise this messes with the order of positional arguments.
I think this should work! as soon as |
|
On there other hand, there are a few things that I don't yet understand:
cmd = {
'prefix': 'orch daemon add',
'daemon_type': 'placement=smithi044:[v2:172.21.15.44:3301,v1:172.21.15.44:6790]=c'',
'placement': 'daemon_type=mon`,
}which is a bit questionable.
|
Somewhat contrived but yes. My solution would have been to require a flag when the argument is defined in the module. Consider if we'd require a flag like
Motivation for this is for modules that have a lot of arguments that have default values. If a user wants to specify only one of those arguments, without the kwargs extension they would have to pass the preceding arguments in the right order. So this should add quite a bit of convenience for users.
|
Interesting. I'm facing the same issue with the orch commands. Especially monsters like ceph/src/pybind/mgr/orchestrator/module.py Lines 1098 to 1110 in 46c9129 with users passing really does wrong things. Anyway. you want to make a new PR? |
Sure thing. |
|
@neha-ojha might want to add this PR to your batches, as |
|
Hm. An idea would be to get this merged now to fix the rados suite and then follow-up with a proper refactorization. @jan--f would that work? |
@sebastian-philipp could you please do me a favor and ping me as well when we have such a failure in future? |
Sure or a revert would work too. I should have a proper fix later today. |
|
Hm. ok then let's merge this and revert (while keeping the pytest) this commit in your PR? |
Make parsing of keyword arguments a bit safer by
makeing sure the key is actually a valid parameter name
Fixes: https://tracker.ceph.com/issues/47185
Signed-off-by: Sebastian Wagner sebastian.wagner@suse.com
Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume tox