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
argparse: add positional=false option #33164
Conversation
@matthewoliver what do you think? |
Note that I think we can fix https://tracker.ceph.com/issues/42113 in a better way: allow --format to be specified for any command. It's silly that we have to specify it as a param for that one 'orchestrator device ls'. |
Kk, will flip it around :) makes sense.
Matt
…On Sun., 9 Feb. 2020, 1:27 pm Sage Weil ***@***.*** wrote:
Note that I think we can fix https://tracker.ceph.com/issues/42113 in a
better way: allow --format to be specified for any command. It's silly that
we have to specify it as a param for that one 'orchestrator device ls'.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#33164?email_source=notifications&email_token=AAAK3S4GNVJIXQD5WCJBZ2TRB5S2NA5CNFSM4KR6RWKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELGAWIQ#issuecomment-583797538>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAK3S4IH7CAWYJMCOOPL7DRB5S2NANCNFSM4KR6RWKA>
.
|
the comment posted at #33135 also applies. |
hrm, ceph.in chokes on unexpected keys in the description:
|
src/pybind/ceph_argparse.py
Outdated
@@ -1024,6 +1085,7 @@ def validate(args, signature, flags=0, partial=False): | |||
validate_one(kwarg_v, kwarg_desc) | |||
matchcnt += 1 | |||
store_arg(kwarg_desc, d) | |||
matchcnt += 1 |
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.
Incrementing matchcnt is now redundant, back when the patch was first created it was required. But since I've pushed a PR that has since merged that did just this to fix #33004 (now just needs to be back ported)
@@ -442,7 +442,7 @@ class CephOsdName(CephArgtype): | |||
|
|||
osd.<id>, or <id>, or *, where id is a base10 int | |||
""" | |||
def __init__(self): | |||
def __init__(self, **kwargs): |
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.
i don't understand this change, as argdesc.__init__()
is the only place where we construct these CephArgtype
instances. but since this method's signature looks like
def __init__(self, t, name=None, n=1, req=True, positional=True, **kwargs):
any unknown parameter should be consumed by CephArgtype
already. actually after reverting this change and applying following patch
diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py
index b8d4664cf8..8782b6a70a 100644
--- a/src/pybind/ceph_argparse.py
+++ b/src/pybind/ceph_argparse.py
@@ -509,7 +509,7 @@ class CephBool(CephArgtype):
A boolean argument, values may be case insensitive 'true', 'false', '0',
'1'. In keyword form, value may be left off (implies true).
"""
- def __init__(self, strings='', **kwargs):
+ def __init__(self, strings=''):
self.strings = strings.split('|')
def valid(self, s, partial=False):
i ran following tests:
$ bin/ceph config set global mon_warn_on_pool_pg_num_not_power_of_two false --force=false
$ bin/ceph config set global mon_warn_on_pool_pg_num_not_power_of_two true
$ bin/ceph orch device ls gnit json
Error ENOENT: No orchestrator configured (try `ceph orch set backend`)
needs rebase |
ping? |
Rebased, but htis depends on #34272 |
Just wondering, does this PR have any relation to https://tracker.ceph.com/issues/43114 ? |
Not related. I think this is a useful cleanup/step forward for the CLI overall, but I was nervous about merging just prior to octopus. Now would be a good time to rebase and retest this, but hopefully someone can adopt it? |
retest this please |
This patch adds an new parameter to the argdesc class, `param` that when set to `true` will force the `--name=` syntax in the generated helpstr. The `param=true` is also added to the `fomat` option of the `ceph orchestrator device ls` command so the specified usage wont result in a cli syntax error. This patch also modifies the ceph client to remove any param=true argdesc's from the srgs and deals with them non positionally. Fixes: https://tracker.ceph.com/issues/42113 Signed-off-by: Matthew Oliver <moliver@suse.com>
Signed-off-by: Sage Weil <sage@redhat.com>
Signed-off-by: Sage Weil <sage@redhat.com>
Signed-off-by: Sage Weil <sage@redhat.com>
If the argdesc we are passed by the server has fields we do not recognize, we currently choke with something like Traceback (most recent call last): File "bin/ceph", line 1271, in <module> retval = main() File "bin/ceph", line 1050, in main return do_extended_help(parser, childargs, target, ' '.join(childargs)) File "bin/ceph", line 416, in do_extended_help return help_for_target(target, partial) File "bin/ceph", line 413, in help_for_target return help_for_sigs(outbuf.decode('utf-8'), partial) File "bin/ceph", line 391, in help_for_sigs sys.stdout.write(format_help(parse_json_funcsigs(sigs, 'cli'), File "/home/sage/src/ceph3/src/pybind/ceph_argparse.py", line 847, in parse_json_funcsigs cmd['sig'] = parse_funcsig(cmd['sig']) File "/home/sage/src/ceph3/src/pybind/ceph_argparse.py", line 797, in parse_funcsig **kwargs)) File "/home/sage/src/ceph3/src/pybind/ceph_argparse.py", line 673, in __init__ self.instance = self.t(**self.typeargs) TypeError: __init__() got an unexpected keyword argument 'positional' At least, most types do: CephBool does not. Make all of the types tolerate extra (new) fields. This will make future additions less painful. Signed-off-by: Sage Weil <sage@redhat.com>
There are lots of CephBool parameters this applies too, but they already look like non-positional arguments (as far as I can tell, at least). There is *one* other command: COMMAND("pg dump_stuck " "name=stuckops,type=CephChoices,strings=inactive|unclean|stale|undersized|degraded,n=N,req=false " \ "name=threshold,type=CephInt,req=false", In this case previously you could do 'pg dump_stuck inactive 123' and the parser could tell 123 was not part of the stuckops list because it wasn't in the enum. With this PR you now have to do ceph pg dump_stuck inactive --threshold 123 IMO this is an improvement as it more closely aligns with how other parsers work and is less ambiguous. Signed-off-by: Sage Weil <sage@redhat.com>
Signed-off-by: Sage Weil <sage@redhat.com>
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution! |
Allow argdesc to contain 'positional=false', which makes an arg not parsed positionally, requiring the --foo[= [value syntax.
Fixes: https://tracker.ceph.com/issues/42113
Replaces #31042
Based on top of #33135