Skip to content

mgr/volumes: validate subvolume create cmd args#50028

Closed
mchangir wants to merge 6 commits intoceph:mainfrom
mchangir:mds-handle-bad-arguments-during-subvolume-create
Closed

mgr/volumes: validate subvolume create cmd args#50028
mchangir wants to merge 6 commits intoceph:mainfrom
mchangir:mds-handle-bad-arguments-during-subvolume-create

Conversation

@mchangir
Copy link
Contributor

@mchangir mchangir commented Feb 8, 2023

test subvolgroup and subvol names and declare empty/whitespace strings as bad names

Fixes: https://tracker.ceph.com/issues/58645
Signed-off-by: Milind Changire mchangir@redhat.com

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

@github-actions github-actions bot added cephfs Ceph File System pybind labels Feb 8, 2023
@mchangir mchangir self-assigned this Feb 8, 2023
@mchangir mchangir force-pushed the mds-handle-bad-arguments-during-subvolume-create branch from 700c853 to 1cc6a1c Compare February 8, 2023 13:32
@vshankar vshankar requested a review from a team February 8, 2023 13:38
@kotreshhr kotreshhr self-requested a review February 8, 2023 13:40
@mchangir mchangir force-pushed the mds-handle-bad-arguments-during-subvolume-create branch from 1cc6a1c to e48c709 Compare February 9, 2023 07:46
@mchangir
Copy link
Contributor Author

mchangir commented Feb 9, 2023

Update:
Replaced word group with subvolgroup in PR description and commit message.

@vshankar
Copy link
Contributor

@mchangir Do we know why the string (subvolume, group) isn't caught before even getting called into the volumes driver?

@mchangir
Copy link
Contributor Author

@mchangir Do we know why the string (subvolume, group) isn't caught before even getting called into the volumes driver

AFAICT, its the volumes driver that enforces all the rules on the subvolume and group naming, which, I think, is the right place do such validations

@rishabh-d-dave
Copy link
Contributor

jenkins test make check

Copy link
Contributor

@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.

Looks okay to me.

@vshankar
Copy link
Contributor

@mchangir Do we know why the string (subvolume, group) isn't caught before even getting called into the volumes driver

AFAICT, its the volumes driver that enforces all the rules on the subvolume and group naming, which, I think, is the right place do such validations

Right. However, in this case its a empty string that getting passed in. I expected this to be caught before calling into the volumes driver.

@mchangir
Copy link
Contributor Author

@mchangir Do we know why the string (subvolume, group) isn't caught before even getting called into the volumes driver

AFAICT, its the volumes driver that enforces all the rules on the subvolume and group naming, which, I think, is the right place do such validations

Right. However, in this case its a empty string that getting passed in. I expected this to be caught before calling into the volumes driver.

There's a way to mention what are the acceptable characters for a parameter via the goodchars spec.

Is there a way to mention in the command parameter spec that the argument also needs to be non-empty string ?

Where can I find the parameter spec attributes definitions ?
Maybe I could add a spec to specify non-empty string.

@vshankar
Copy link
Contributor

@mchangir Do we know why the string (subvolume, group) isn't caught before even getting called into the volumes driver

AFAICT, its the volumes driver that enforces all the rules on the subvolume and group naming, which, I think, is the right place do such validations

Right. However, in this case its a empty string that getting passed in. I expected this to be caught before calling into the volumes driver.

There's a way to mention what are the acceptable characters for a parameter via the goodchars spec.

Is there a way to mention in the command parameter spec that the argument also needs to be non-empty string ?

Where can I find the parameter spec attributes definitions ? Maybe I could add a spec to specify non-empty string.

Something along those lines. I think other mgr modules just might have the similar issues with empty strings.

@mchangir
Copy link
Contributor Author

@mchangir Do we know why the string (subvolume, group) isn't caught before even getting called into the volumes driver

AFAICT, its the volumes driver that enforces all the rules on the subvolume and group naming, which, I think, is the right place do such validations

Right. However, in this case its a empty string that getting passed in. I expected this to be caught before calling into the volumes driver.

There's a way to mention what are the acceptable characters for a parameter via the goodchars spec.
Is there a way to mention in the command parameter spec that the argument also needs to be non-empty string ?
Where can I find the parameter spec attributes definitions ? Maybe I could add a spec to specify non-empty string.

Something along those lines. I think other mgr modules just might have the similar issues with empty strings.

I looked up other mgr/volumes create commands. The only ones found were:

  • fs subvolumegroup create
  • fs subvolumegroup snapshot create
  • fs subvolume create
  • fs subvolume snapshot create

The subvolume* snapshot create commands fail with various errors without explicit argument validation and hence haven't had this issue before.

e.g. fs snap-schedule add command never validates input arguments for fs and path, the effect of validation only takes place when the actual snapshot creation is attempted and then the snap-schedule is deactivated or when the INSERT into the DB happens via the DB field/column constraints

@mchangir mchangir force-pushed the mds-handle-bad-arguments-during-subvolume-create branch 2 times, most recently from 2fae36a to d189976 Compare February 21, 2023 08:38
@mchangir mchangir requested a review from a team as a code owner February 21, 2023 09:07
@dparmar18
Copy link
Contributor

changes in src/pybind/ceph_argparse.py seems to have broken something:

FAIL: test_parse_json_funcsigs (__main__.ParseJsonFuncsigs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jenkins-build/build/workspace/ceph-pull-requests/src/test/pybind/test_ceph_argparse.py", line 46, in test_parse_json_funcsigs
    self.assertRaises(TypeError, parse_json_funcsigs, commands, 'cli')
AssertionError: TypeError not raised by parse_json_funcsigs

----------------------------------------------------------------------
Ran 136 tests in 58.276s

FAILED (failures=1)
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name=4 encoding='UTF-8'>

https://jenkins.ceph.com/job/ceph-pull-requests/110979/consoleText

@mchangir mchangir force-pushed the mds-handle-bad-arguments-during-subvolume-create branch from 7702dd0 to 0792920 Compare February 21, 2023 15:28
@mchangir
Copy link
Contributor Author

@vshankar this is ready for review

@vshankar
Copy link
Contributor

@vshankar this is ready for review

Please add a test for the fix.

@vshankar vshankar requested a review from ljflores February 22, 2023 02:51
@github-actions github-actions bot added the tests label Feb 22, 2023
@mchangir mchangir force-pushed the mds-handle-bad-arguments-during-subvolume-create branch from e41ef18 to 8cf591a Compare February 22, 2023 13:27
@vshankar
Copy link
Contributor

vshankar commented Jun 23, 2023

@ljflores This touches ceph_argparse python source, would you be the one to review that?

EDIT: Changes LGTM, but wanted someone from the relevant team to have a look.

@ljflores ping? Could you please have a look.

EDIT: relevant tests in fs suite run fine.

@vshankar
Copy link
Contributor

Copy link
Contributor

@vshankar vshankar left a comment

Choose a reason for hiding this comment

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

@mchangir mchangir force-pushed the mds-handle-bad-arguments-during-subvolume-create branch from e11d782 to e6fe801 Compare June 27, 2023 16:18
@mchangir
Copy link
Contributor Author

Fixed a bug introduced by commit bf83eaa. The commit had introduced a spurious empty string as a command-line argument to fs subvolume create command if no subvol_options section was found in the job config.

A sanity job run mostly passes with the changes.

@vshankar
Copy link
Contributor

vshankar commented Jul 3, 2023

Fixed a bug introduced by commit bf83eaa. The commit had introduced a spurious empty string as a command-line argument to fs subvolume create command if no subvol_options section was found in the job config.

A sanity job run mostly passes with the changes.

Thx @mchangir. I think there is merit running this change through other subsystem suites.

@vshankar
Copy link
Contributor

vshankar commented Jul 4, 2023

ping @ljflores

@github-actions
Copy link

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

mchangir added 6 commits July 13, 2023 14:11
Signed-off-by: Milind Changire <mchangir@redhat.com>
Signed-off-by: Milind Changire <mchangir@redhat.com>
tag subvolumegroup and subvolume args with allowempty=false for
validation

Fixes: https://tracker.ceph.com/issues/58645
Signed-off-by: Milind Changire <mchangir@redhat.com>
Signed-off-by: Milind Changire <mchangir@redhat.com>
Signed-off-by: Milind Changire <mchangir@redhat.com>
Signed-off-by: Milind Changire <mchangir@redhat.com>
@mchangir mchangir force-pushed the mds-handle-bad-arguments-during-subvolume-create branch from e6fe801 to d27b6ff Compare July 13, 2023 08:42
@mchangir
Copy link
Contributor Author

rebased

@mchangir mchangir requested a review from vshankar July 13, 2023 08:45
@github-actions
Copy link

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.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions bot added the stale label Sep 11, 2023
@github-actions
Copy link

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!

@github-actions github-actions bot closed this Oct 11, 2023
@mchangir mchangir removed the stale label Oct 11, 2023
@vshankar
Copy link
Contributor

@mchangir

@vshankar
Copy link
Contributor

ropening...

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants