ceph.in: allow 'flags' to not be present in cmddescs #12540

Merged
merged 1 commit into from Dec 20, 2016

Projects

None yet

5 participants

@dmick
Member
dmick commented Dec 16, 2016

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

@dmick dmick ceph.in: allow 'flags' to not be present in cmddescs
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>
e72c801
@dmick dmick assigned dmick, zmc, and batrick and unassigned dmick Dec 16, 2016
@dmick dmick requested review from zmc and batrick Dec 16, 2016
@zmc zmc was unassigned by dmick Dec 16, 2016
@liewegas liewegas added this to the kraken milestone Dec 17, 2016
@alfredodeza

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
@alfredodeza
alfredodeza Dec 20, 2016 Contributor

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?

@liewegas
liewegas Dec 20, 2016 Member

I don't think it can be changed without chagning hte json schema...

@alfredodeza
alfredodeza Dec 20, 2016 Contributor

I mean, it is not necessary to use &, |, or << here. Regular Python operators would do just fine.

@dmick
dmick Dec 20, 2016 Member

just saw this. It seems like idiomatic usage to me, but then I'm a C programmer first

@liewegas liewegas merged commit e0903c9 into ceph:master Dec 20, 2016

3 checks passed

Signed-off-by all commits in this PR are signed
Details
Unmodifed Submodules submodules for project are unmodified
Details
default Build finished.
Details
@dmick dmick deleted the dmick:wip-18297 branch Dec 20, 2016
@batrick
Contributor
batrick commented Jan 9, 2017

I was on PTO when you requested this review. It looks good. Thanks for fixing this @dmick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment