Skip to content

pybind/ceph_argparse: Fix error message for ceph tell command - #51332

Merged
vshankar merged 2 commits into
ceph:mainfrom
neesingh-rh:wip_59624
Aug 1, 2024
Merged

vshankar merged 2 commits into
ceph:mainfrom
neesingh-rh:wip_59624

Conversation

@neesingh-rh

@neesingh-rh neesingh-rh commented May 3, 2023 •

Copy link
Copy Markdown
Contributor

$ceph tell cephfs_1.magna023.yvyxvl client ls
error handling command target: local variable 'poolid' referenced before assignment

The error message local variable 'poolid' referenced before assignment looks not descriptive. The exception was not getting raised by the usage of ArgumentValid which was getting bypassed and hence code asks for poolid when no type has been provided in tell commands.

Now after this fix, we are getting the proper error message as type is unknown for above example.

Fixes: https://tracker.ceph.com/issues/59624
Signed-off-by: Neeraj Pratap Singh [email protected]

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 the pybind label May 3, 2023
@neesingh-rh

neesingh-rh commented May 3, 2023 •

Copy link
Copy Markdown
Contributor Author

After experimenting with all the classes inheriting CephArgtype in src/pybind/ceph_argparse.py for exception , I found this works with JsonFormat only. Another option that I found is to directly raise ValueError or TypeError, it works with them too.

@vshankar
vshankar requested review from a team May 3, 2023 12:07
@neesingh-rh
neesingh-rh requested a review from tchaikov June 7, 2023 07:37
Comment thread src/pybind/ceph_argparse.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

in addition to the outcome of the fix, please explain the reason why this change fixes the symptom you were seeing in the commit message. and a test case would be great.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

per the docstring of JsonFormat

some syntactic or semantic issue with the JSON

but this is not a JSON related error. so i am inclined not using JsonFormat here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, I'm left confused by this as well. Perhaps ArgumentValid was caught up the stack and this JsonFormat avoids that? This looks hacky.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup! I went through the code again and re-debugged each flows, where I found that when find_cmd_target() is trying to validate the command by calling CephName and CephPgid, it is failing in the valid() of CephPgid where it is trying to access a variable poolid in the except clause, which isn't assigned yet due to error there. Now, the code works as expected and we are getting the proper error message for wrong cephname type i.e. unknown type ....

@neesingh-rh

Copy link
Copy Markdown
Contributor Author

jenkins retest this please

@tchaikov tchaikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

$ceph tell cephfs_1.magna023.yvyxvl client ls
error handling command target: local variable 'poolid' referenced before assignment

the error message local variable 'poolid' referenced before assignment looks not descriptive.
The exception was not getting raised by the usage of ArgumentValid and hence code asks for poolid which is

what's the connection between ArgumentValid and poolid?

i still don't get why / where poolid is referenced

Comment thread src/pybind/ceph_argparse.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

per the docstring of JsonFormat

some syntactic or semantic issue with the JSON

but this is not a JSON related error. so i am inclined not using JsonFormat here.

Comment thread src/pybind/ceph_argparse.py Outdated
int(i)
except ValueError:
raise ArgumentFormat(f'osd id {i} not integer')
raise JsonFormat(f'osd id {i} not integer')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto.

Comment thread src/test/pybind/test_ceph_argparse.py Resolved
@tchaikov

Copy link
Copy Markdown
Contributor

Error message is not descriptive for ceph tell ……command

the title of the commit message reads like a bug report. ideally, the title of the commit message should use the imperative mood. see also https://github.com/ceph/ceph/blob/master/SubmittingPatches.rst#3-describe-your-changes . please use git commit --amend and git push -f for revising the commit message and its title.

@neesingh-rh
neesingh-rh force-pushed the wip_59624 branch 2 times, most recently from d04de87 to 72da79f Compare August 29, 2023 11:58
@neesingh-rh neesingh-rh changed the title pybind/ceph_argparse: Error message is not descriptive for ceph tell command pybind/ceph_argparse: Fix error message for ceph tell command Aug 29, 2023
Comment thread src/test/pybind/test_ceph_argparse.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be a separate test.

Comment thread src/test/pybind/test_ceph_argparse.py Resolved
Comment thread src/pybind/ceph_argparse.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, I'm left confused by this as well. Perhaps ArgumentValid was caught up the stack and this JsonFormat avoids that? This looks hacky.

@neesingh-rh

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@github-actions

github-actions Bot commented Jan 7, 2024

Copy link
Copy Markdown

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 Jan 7, 2024
@tchaikov tchaikov removed the stale label Jan 7, 2024
@tchaikov

tchaikov commented Jan 7, 2024

Copy link
Copy Markdown
Contributor

jenkins test make check

@rishabh-d-dave rishabh-d-dave removed needs-qa wip-rishabh-testing Rishabh's testing label labels Jul 11, 2024
@rishabh-d-dave

Copy link
Copy Markdown
Contributor

Talked with Venky about this PR, he wants approval from core before merging.

@rishabh-d-dave
rishabh-d-dave requested a review from a team July 11, 2024 17:11
@vshankar

Copy link
Copy Markdown
Contributor

Talked with Venky about this PR, he wants approval from core before merging.

Tagging @ljflores

@github-actions

Copy link
Copy Markdown

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

@tchaikov tchaikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@tchaikov

Copy link
Copy Markdown
Contributor

@neesingh-rh could you please rebase this change?

@neesingh-rh

Copy link
Copy Markdown
Contributor Author

rebased!!

@neesingh-rh

Copy link
Copy Markdown
Contributor Author

Talked with Venky about this PR, he wants approval from core before merging.

@rishabh-d-dave We do have an approval from @tchaikov ,it is ready to merge.

@rishabh-d-dave

Copy link
Copy Markdown
Contributor

Talked with Venky about this PR, he wants approval from core before merging.

@rishabh-d-dave We do have an approval from @tchaikov ,it is ready to merge.

Since RADOS will also be affected by this change, I suppose it's better to do RADOS QA as well? cc @vshankar @ljflores

@neesingh-rh

Copy link
Copy Markdown
Contributor Author

Talked with Venky about this PR, he wants approval from core before merging.

@rishabh-d-dave We do have an approval from @tchaikov ,it is ready to merge.

Since RADOS will also be affected by this change, I suppose it's better to do RADOS QA as well? cc @vshankar @ljflores

@rishabh-d-dave Can we priotize this PR for testing, as we do have BZ targeting 6.1z7 and for this blocker only is tomorrow. If we can by today, otherwise let me know. I will have reply there?

@rishabh-d-dave

Copy link
Copy Markdown
Contributor

Talked with Venky about this PR, he wants approval from core before merging.

@rishabh-d-dave We do have an approval from @tchaikov ,it is ready to merge.

Since RADOS will also be affected by this change, I suppose it's better to do RADOS QA as well? cc @vshankar @ljflores

@rishabh-d-dave Can we priotize this PR for testing, as we do have BZ targeting 6.1z7 and for this blocker only is tomorrow. If we can by today, otherwise let me know. I will have reply there?

From CephFS side it's already tested successfully, that's all I can do. Venky and core team are better position to tell whether to merge this or proceed for RADOS QA run.

@rishabh-d-dave

Copy link
Copy Markdown
Contributor

Talked with Venky about this PR, he wants approval from core before merging.

@rishabh-d-dave We do have an approval from @tchaikov ,it is ready to merge.

Since RADOS will also be affected by this change, I suppose it's better to do RADOS QA as well? cc @vshankar @ljflores

@vshankar @ljflores This has BZ associated with this, please check if this can be merged.

@vshankar

Copy link
Copy Markdown
Contributor

Talked with Venky about this PR, he wants approval from core before merging.

@rishabh-d-dave We do have an approval from @tchaikov ,it is ready to merge.

Since RADOS will also be affected by this change, I suppose it's better to do RADOS QA as well? cc @vshankar @ljflores

@vshankar @ljflores This has BZ associated with this, please check if this can be merged.

@neesingh-rh mentioned that @tchaikov has approved this, so IMO this is good to merge.

@rishabh-d-dave

Copy link
Copy Markdown
Contributor

@vshankar Had a chat with Venky about this PR, we need to run other QA suites as well.

@rishabh-d-dave

Copy link
Copy Markdown
Contributor

@vshankar Had a chat with Venky about this PR, we need to run other QA suites as well.

@yuriw This PR has passed CephFS QA suits and has been approved by @tchaikov. Can you please include it in your QA runs?

@vshankar

vshankar commented Aug 1, 2024

Copy link
Copy Markdown
Contributor

@vshankar Had a chat with Venky about this PR, we need to run other QA suites as well.

@yuriw This PR has passed CephFS QA suits and has been approved by @tchaikov. Can you please include it in your QA runs?

Had a conversation with @neesingh-rh regarding this change. This started out as a different change, but ended up just as a fix in the error message. IMO, this is good to merge.

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