Skip to content
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

pybind/mgr: generalize CLICheckNonemptyFileInput() error msg #41378

Merged
merged 4 commits into from May 27, 2021

Conversation

varshar16
Copy link
Contributor

This PR makes the following changes:

  • checks if file contains only spaces
  • generalize CLICheckNonemptyFileInput() error msg
  • use CLICheckNonemptyFileInput decorator in nfs module

Fixes: https://tracker.ceph.com/issues/50858

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 api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

@varshar16 varshar16 requested a review from a team as a code owner May 18, 2021 09:45
@varshar16 varshar16 requested review from pereman2 and Waadkh7 and removed request for a team May 18, 2021 09:45
@varshar16 varshar16 requested review from alfonsomthd, batrick and a team May 18, 2021 09:45
src/pybind/mgr/dashboard/services/access_control.py Outdated Show resolved Hide resolved
src/pybind/mgr/mgr_module.py Outdated Show resolved Hide resolved
@varshar16 varshar16 force-pushed the wip-check-file-inputs-nfs branch 2 times, most recently from a9d2f2a to cbd344d Compare May 19, 2021 06:09
@varshar16
Copy link
Contributor Author

Fixed mypy errors

mgr_module.py: note: In function "CLICheckNonemptyFileInput":
mgr_module.py:428: error: Incompatible return value type (got "Callable[[Callable[..., Tuple[int, str, str]]], Callable[..., Tuple[int, str, str]]]", expected "Callable[..., Tuple[int, str, str]]")
dashboard/services/auth.py:16: note: In module imported here,
dashboard/module.py:33: note: ... from here,
dashboard/__init__.py:55: note: ... from here:
dashboard/services/access_control.py:552: error: Argument 1 to "__call__" of "CLICommand" has incompatible type "Tuple[int, str, str]"; expected "Callable[..., Tuple[int, str, str]]"
dashboard/services/access_control.py:691: error: Argument 1 to "__call__" of "CLICommand" has incompatible type "Tuple[int, str, str]"; expected "Callable[..., Tuple[int, str, str]]"
dashboard/services/access_control.py:845: error: Argument 1 to "__call__" of "CLICommand" has incompatible type "Tuple[int, str, str]"; expected "Callable[..., Tuple[int, str, str]]"
dashboard/services/access_control.py:867: error: Argument 1 to "__call__" of "CLICommand" has incompatible type "Tuple[int, str, str]"; expected "Callable[..., Tuple[int, str, str]]"
dashboard/module.py:36: note: In module imported here,
dashboard/__init__.py:55: note: ... from here:
dashboard/settings.py: note: In function "handle_option_command":
dashboard/settings.py:243: error: "Tuple[object, ...]" not callable
dashboard/controllers/iscsi.py:20: note: In module imported here,
dashboard/plugins/feature_toggles.py:11: note: ... from here,
dashboard/module.py:54: note: ... from here,
dashboard/__init__.py:55: note: ... from here:
dashboard/services/iscsi_cli.py:25: error: Argument 1 to "__call__" of "CLICommand" has incompatible type "Tuple[int, str, str]"; expected "Callable[..., Tuple[int, str, str]]"

@alfonsomthd alfonsomthd requested a review from epuertat May 19, 2021 06:29
@varshar16
Copy link
Contributor Author

Fixed flake8 error

lint run-test: commands[0] | flake8
[NON-XML-CHAR-0x1B][0;36m./services/access_control.py[NON-XML-CHAR-0x1B][0m:[NON-XML-CHAR-0x1B][1;33m31[NON-XML-CHAR-0x1B][0m:[NON-XML-CHAR-0x1B][1;32m1[NON-XML-CHAR-0x1B][0m: [NON-XML-CHAR-0x1B][1;31mE302[NON-XML-CHAR-0x1B][0m expected 2 blank lines, found 1
1     E302 expected 2 blank lines, found 1

@varshar16
Copy link
Contributor Author

@batrick
Copy link
Member

batrick commented May 20, 2021

@ceph/dashboard please run this through your QA when you can.

Copy link
Member

@epuertat epuertat left a comment

Choose a reason for hiding this comment

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

LGTM @varshar16 ! Just left a few suggestions over there.

Comment on lines 40 to 41
ERROR_MSG_EMPTY_INPUT_FILE = 'File is empty!!'
ERROR_MSG_NO_INPUT_FILE = 'No Input File!!'
Copy link
Member

Choose a reason for hiding this comment

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

Nit, but 2 exclamation marks might sound a bit... over-emphatic :P

I just grepped our source code (grep "[\"'][^\"']*\![^\"'][\"']" * -Ri --include="*.[py, h*,c*]") and found that it's not frequent in Ceph code (only in some deps, like zstd or civetweb).

What about using the POSIX errno style:

  • Empty input file: {details}
  • Input file not specified: {details}

This is probably more of a discussion for docs experts: @knortema ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting stack overflow discussion. I have updated the message.

Comment on lines 417 to 418
return -errno.EINVAL, '', f'{ERROR_MSG_NO_INPUT_FILE} Please specify the file '\
f'containing {content} with "-i" option'
Copy link
Member

Choose a reason for hiding this comment

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

What about using HandleCommandResult() helper instead of the raw tuple (retval, stdout, stderr)?

Suggested change
return -errno.EINVAL, '', f'{ERROR_MSG_NO_INPUT_FILE} Please specify the file '\
f'containing {content} with "-i" option'
return HandleCommandResult(
-errno.EINVAL,
'',
f'{ERROR_MSG_NO_INPUT_FILE} Please specify the file '\
f'containing {content} with "-i" option'
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

@varshar16 varshar16 May 25, 2021

Choose a reason for hiding this comment

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

Reverted this change. As it requires multiple files to be updated. It is best to be done in a different PR.

src/pybind/mgr/mgr_module.py Outdated Show resolved Hide resolved
src/pybind/mgr/mgr_module.py Outdated Show resolved Hide resolved
@varshar16
Copy link
Contributor Author

@epuertat Thanks for the review. I have updated the PR, please take another look.

Copy link
Member

@epuertat epuertat left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments. Looks good, @varshar16!! (worthy to add some exclamation marks :-P)

@varshar16
Copy link
Contributor Author

jenkins test dashboard

@github-actions
Copy link

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

Signed-off-by: Varsha Rao <varao@redhat.com>
Signed-off-by: Varsha Rao <varao@redhat.com>
@varshar16
Copy link
Contributor Author

Rebased

@varshar16
Copy link
Contributor Author

jenkins test make check

@varshar16
Copy link
Contributor Author

@tchaikov tchaikov merged commit 8bc2c6d into ceph:master May 27, 2021
@varshar16 varshar16 deleted the wip-check-file-inputs-nfs branch May 27, 2021 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants