Skip to content

rgw: cleanup special handling of errors - #59984

Closed
tobias-urdin wants to merge 1 commit into
ceph:mainfrom
tobias-urdin:rgw-special-errors-cleanup
Closed

tobias-urdin wants to merge 1 commit into
ceph:mainfrom
tobias-urdin:rgw-special-errors-cleanup

Conversation

@tobias-urdin

Copy link
Copy Markdown
Contributor

This changes the rgw_http_errors from being a pair to a tuple that now also includes a potential default error message.

This removes the special cases added in the code just to be able to set an error message in a good way.

This changes the error message for an expired presigned URL to "Request has expired" as per the AWS S3 [1] standard message.

A future improvement here is addressing the comment about cleaning up the error handling in Swift, another improvement is getting rid of the set_req_state_err() signature that takes in a error message and rework that to something like set_req_state_err_msg and rely on everything else by default from rgw_http_errors.

[1] https://repost.aws/knowledge-center/request-has-expired-s3-object

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

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
  • jenkins test rook e2e

This changes the rgw_http_errors from being a pair
to a tuple that now also includes a potential default
error message.

This removes the special cases added in the code just
to be able to set an error message in a good way.

This changes the error message for an expired presigned
URL to "Request has expired" as per the AWS S3 [1]
standard message.

A future improvement here is addressing the comment about
cleaning up the error handling in Swift, another improvement
is getting rid of the set_req_state_err() signature that
takes in a error message and rework that to something like
set_req_state_err_msg and rely on everything else by default
from rgw_http_errors.

[1] https://repost.aws/knowledge-center/request-has-expired-s3-object

Signed-off-by: Tobias Urdin <[email protected]>
@tobias-urdin
tobias-urdin requested a review from a team as a code owner September 25, 2024 19:48
@github-actions github-actions Bot added the rgw label Sep 25, 2024

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

overall i'm not sure that i prefer this approach to what we have now. this pr seems to assume there's a one-to-one mapping from error codes to messages, which is very much not the case - especially for EINVAL which generally tries to say exactly which request parameter is wrong

Comment thread src/rgw/rgw_rest_s3.cc
e->s3_code = r->second.second;
e->http_ret = std::get<0>(r->second);
e->s3_code = std::get<1>(r->second);
e->message = std::get<2>(r->second);

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.

if an op has already set s->err.message, this would overwrite it

in most cases (all?), ops that set s->err.message do so before their call to set_req_state_err()

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.

not sure if i follow, i can't see that this touches req_state (s) anywhere and is just a helper function to get an error by number a populate the struct referenced by a pointer (e)...?

but i agree that this might need more testing unless we have a lot of functional testing that verifies error messages returned

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.

sorry, you're right about rgw_get_errno_s3()

search_err() from rgw_common.cc is the one that would overwrite s->err.message when called by set_req_state_err(req_state* s, int err_no)

@cbodley cbodley removed the needs-qa label Sep 30, 2024
@tobias-urdin

tobias-urdin commented Sep 30, 2024 •

Copy link
Copy Markdown
Contributor Author

overall i'm not sure that i prefer this approach to what we have now. this pr seems to assume there's a one-to-one mapping from error codes to messages, which is very much not the case - especially for EINVAL which generally tries to say exactly which request parameter is wrong

I understand, it's a good mini project to get more familiar with other parts of the codebase. My idea was to get rid of hacky approach of checking the return value for a specific error just to translate it to another one and instead just return the original error in the function and handle it like "any other error" when it gets passed down.

This could need some more polishing and testing for sure unless we are sure that we test error message in responses for most/all API calls we test (we probably don't for most API calls would be my guess?).

My plan for those that are special is to get rid of some function signatures for set_req_state_err and instead do something like set_req_state_err_msg or similar that is set by the function returning the error down the chain.

Either way – let's ignore this for now and I'll respin this with a more complete approach if I get some time over to deep-dive more since the immediate issue is solved with 500 API error with the other patch.

Comment thread src/rgw/rgw_rest_s3.cc

ops_log_entry.error = true;
ops_log_entry.http_status = r.http_ret;
ops_log_entry.error_message = r.s3_code;

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.

todo: this should probaby be ops_log_entry.error_message = r.message

Comment thread src/rgw/rgw_rest_s3.cc
e->s3_code = r->second.second;
e->http_ret = std::get<0>(r->second);
e->s3_code = std::get<1>(r->second);
e->message = std::get<2>(r->second);

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.

not sure if i follow, i can't see that this touches req_state (s) anywhere and is just a helper function to get an error by number a populate the struct referenced by a pointer (e)...?

but i agree that this might need more testing unless we have a lot of functional testing that verifies error messages returned

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants