Skip to content

MDSAuthCaps: print better error message for perm flag in MDS caps#52042

Merged
rishabh-d-dave merged 3 commits intoceph:mainfrom
rishabh-d-dave:better-errmsg-for-perm
Sep 22, 2023
Merged

MDSAuthCaps: print better error message for perm flag in MDS caps#52042
rishabh-d-dave merged 3 commits intoceph:mainfrom
rishabh-d-dave:better-errmsg-for-perm

Conversation

@rishabh-d-dave
Copy link
Contributor

@rishabh-d-dave rishabh-d-dave commented Jun 13, 2023

Permissions mentioned in MDS caps flags can either begin with "r" or
"rw", but it can't start with "w" or be just "w". This is confusing for
some CephFS users since MON caps can be just "w".

Command "ceph fs authorize" informs users that permission MDS caps have
to start with "r" or "rw" but other commands like "auth add", "auth
caps", "auth get-or-create" don't. Make these commands to print a
helpful message, the way "ceph fs authorize" command does.

https://tracker.ceph.com/issues/61666

Contribution Guidelines

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@rishabh-d-dave rishabh-d-dave requested a review from a team as a code owner June 13, 2023 19:30
@rishabh-d-dave rishabh-d-dave requested a review from a team June 13, 2023 19:30
@rishabh-d-dave rishabh-d-dave force-pushed the better-errmsg-for-perm branch 2 times, most recently from 3a8120a to 09f016f Compare June 13, 2023 19:53
@rishabh-d-dave rishabh-d-dave changed the title src/mon/AuthMonitor: add a check for perm flag in MDS caps AuthMonitor: print better error message for perm flag in MDS caps Jun 13, 2023
@rishabh-d-dave rishabh-d-dave force-pushed the better-errmsg-for-perm branch from 09f016f to dcf08d1 Compare June 13, 2023 20:02
@rishabh-d-dave rishabh-d-dave requested a review from vshankar June 14, 2023 13:36
@rishabh-d-dave
Copy link
Contributor Author

jenkins test make check

@rishabh-d-dave rishabh-d-dave force-pushed the better-errmsg-for-perm branch from dcf08d1 to 1e9db39 Compare June 16, 2023 20:49
@rishabh-d-dave
Copy link
Contributor Author

jenkins test api

@rishabh-d-dave rishabh-d-dave force-pushed the better-errmsg-for-perm branch from 1e9db39 to 42ec3b7 Compare June 22, 2023 08:05
@rishabh-d-dave rishabh-d-dave changed the title AuthMonitor: print better error message for perm flag in MDS caps MDSAuthCaps: print better error message for perm flag in MDS caps Jun 22, 2023
@rishabh-d-dave rishabh-d-dave force-pushed the better-errmsg-for-perm branch 3 times, most recently from 8e33571 to fe3e22b Compare June 28, 2023 15:08
@rishabh-d-dave rishabh-d-dave force-pushed the better-errmsg-for-perm branch from fe3e22b to 361eb7b Compare July 11, 2023 15:35
@rishabh-d-dave rishabh-d-dave removed the wip-rishabh-testing Rishabh's testing label label Aug 24, 2023
@rishabh-d-dave rishabh-d-dave force-pushed the better-errmsg-for-perm branch from a2c5d02 to f200f5c Compare August 24, 2023 19:26
@rishabh-d-dave rishabh-d-dave added the wip-rishabh-testing Rishabh's testing label label Aug 24, 2023
Copy link
Contributor Author

@rishabh-d-dave rishabh-d-dave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rishabh-d-dave
Copy link
Contributor Author

jenkins test make check

@rishabh-d-dave
Copy link
Contributor Author

jenkins test make check

After make check passes this PR can be merged.

@rishabh-d-dave
Copy link
Contributor Author

jenkins test make check

@rishabh-d-dave
Copy link
Contributor Author

The make check failure is strange -

flake8: commands[0] /home/jenkins-build/build/workspace/ceph-pull-requests/qa> flake8 --select=F,E9 --exclude=venv,.tox
./tasks/cephfs/cephfs_test_case.py:458:28: F821 undefined name 'StringIO'
flake8: exit 1 (5.34 seconds) /home/jenkins-build/build/workspace/ceph-pull-requests/qa> flake8 --select=F,E9 --exclude=venv,.tox pid=2139318
flake8: FAIL ✖ in 9.49 seconds

But there is not "name" StringIO in these lines -

        if exp_retval is None and exp_errmsgs is None:
            raise RuntimeError('Method didn\'t get enough parameters. Pass '
                               'return value or error message expected from '
                               'the command/process.')

https://jenkins.ceph.com/job/ceph-pull-requests/121500/consoleFull#5759820286733401c-e9d0-4737-9832-6594c5da0afa

@rishabh-d-dave
Copy link
Contributor Author

jenkins test make check

@rishabh-d-dave
Copy link
Contributor Author

Same issue again -

flake8: commands[0] /home/jenkins-build/build/workspace/ceph-pull-requests/qa> flake8 --select=F,E9 --exclude=venv,.tox
./tasks/cephfs/cephfs_test_case.py:458:28: F821 undefined name 'StringIO'
flake8: exit 1 (3.77 seconds) /home/jenkins-build/build/workspace/ceph-pull-requests/qa> flake8 --select=F,E9 --exclude=venv,.tox pid=2482217
flake8: FAIL ✖ in 9.34 seconds

https://jenkins.ceph.com/job/ceph-pull-requests/121516/consoleFull#-1695845042e840cee4-f4a4-4183-81dd-42855615f2c1

@rishabh-d-dave
Copy link
Contributor Author

Same command locally doesn't detect any issue -

$ git branch
* better-errmsg-for-perm
  main
$
$ flake8 --select=F,E9 --exclude=venv,.tox qa/tasks/cephfs/
$

@vshankar
Copy link
Contributor

vshankar commented Sep 7, 2023

Same issue again -

Which means something is boken - checking.

@vshankar
Copy link
Contributor

vshankar commented Sep 7, 2023

# conducting negative testing
kwargs['check_status'] = False
# stderr is needed to check for expected error messages.
kwargs['stderr'] = StringIO()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flake8: commands[0] /home/jenkins-build/build/workspace/ceph-pull-requests/qa> flake8 --select=F,E9 --exclude=venv,.tox
./tasks/cephfs/cephfs_test_case.py:458:28: F821 undefined name 'StringIO'
flake8: exit 1 (5.34 seconds) /home/jenkins-build/build/workspace/ceph-pull-requests/qa> flake8 --select=F,E9 --exclude=venv,.tox pid=2139318
flake8: FAIL ✖ in 9.49 seconds

@rishabh-d-dave It's complaining about this line. make check merges the branch into main before building and running tests.

Copy link
Contributor Author

@rishabh-d-dave rishabh-d-dave Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reply. StringIO is imported at the top of this file, so it can't be undefined. See - https://github.com/rishabh-d-dave/ceph/blob/better-errmsg-for-perm/qa/tasks/cephfs/cephfs_test_case.py#L5.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That import was removed in 4b369cf by you yourself ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, thanks! Following Laura's steps I found out same.

Thank you so much for help!

Also, add comments to explain the users the arguments are accepted by
run_ceph_cmd(), get_ceph_cmd_result(), get_ceph_cmd_stdout() and
negtest_ceph_cmd() methods of class RunCephCmd.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
Permissions mentioned in MDS caps flags can either begin with "r" or
"rw", or can be "*" and "all". But it can't start with or be just "w" or
something else. This is confusing for some CephFS users since MON caps
can be just "w".

Command "ceph fs authorize" complains about this to the user. But other
commands (specifically, "ceph auth add", "ceph auth caps",
"ceph auth get-or-create" and "ceph auth get-or-create-key") don't. Make
these commands too print a helpful message, the way "ceph fs authorize"
command does.

Fixes: https://tracker.ceph.com/issues/61666
Signed-off-by: Rishabh Dave <ridave@redhat.com>
For "fs authorize" command, AuthMonitor.cc checks if permissions is "r"
or begins with "rw". This check is redundant now.
AuthMonitor::valid_caps() runs MDSAuthCaps.parse() which now runs same
check for the MDS caps, regardless of the command.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
Copy link
Contributor Author

@rishabh-d-dave rishabh-d-dave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rishabh-d-dave rishabh-d-dave merged commit c4f968b into ceph:main Sep 22, 2023
@rishabh-d-dave
Copy link
Contributor Author

@vshankar @gregsfortytwo @batrick Should this PR be backported? Leaving the ticket unupdated until then...

@vshankar
Copy link
Contributor

@vshankar @gregsfortytwo @batrick Should this PR be backported? Leaving the ticket unupdated until then...

yes, I think so.

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

Labels

cephfs Ceph File System core mon tests wip-rishabh-testing Rishabh's testing label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants