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
ceph.in: allow 'flags' to not be present in cmddescs #12540
Conversation
the 'flags' key in the command description dict may not be present on older monitors. Check for existence before using it. Introduced in 61d6343 Fixes: http://tracker.ceph.com/issues/18297 Signed-off-by: Dan Mick <dan.mick@redhat.com>
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.
This change seems to fix the problem, but the current implementation (not the fix itself) is really hard to parse and uses unnecessary bitwise operators. It would be great to see those go away and have a simpler approach here
@@ -342,7 +342,9 @@ def format_help(cmddict, partial=None): | |||
|
|||
if not cmd['help']: | |||
continue | |||
if cmd['flags'] is not None and ((cmd['flags'] & (FLAG_OBSOLETE | FLAG_DEPRECATED)) != 0): | |||
flags = cmd.get('flags') | |||
if (flags is not None and |
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.
this explicit check for flags is not None
is clearly fixing the issue, but this is extremely hard to parse due to the uncommon usage of Python's bitwise operators.
Is it really that necessary to use logical bitwise operators to check if a flag is obsolete or deprecated?
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 think it can be changed without chagning hte json schema...
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 mean, it is not necessary to use &
, |
, or <<
here. Regular Python operators would do just fine.
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.
just saw this. It seems like idiomatic usage to me, but then I'm a C programmer first
I was on PTO when you requested this review. It looks good. Thanks for fixing this @dmick. |
the 'flags' key in the command description dict may not be
present on older monitors. Check for existence before
using it.
Introduced in 61d6343
Fixes: http://tracker.ceph.com/issues/18297
Signed-off-by: Dan Mick dan.mick@redhat.com