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

[client] Use application specific error code to propagate ray errors #18278

Merged
merged 9 commits into from
Sep 10, 2021

Conversation

ckw017
Copy link
Member

@ckw017 ckw017 commented Sep 1, 2021

Why are these changes needed?

At the moment there's no way to distinguish error's from ray from grpc INTERNAL errors. This works around this by using an error code that is never generated by the grpc library (details at the bottom of https://grpc.github.io/grpc/core/md_doc_statuscodes.html)

Fixes:
binascii.Error: Invalid base64-encoded string: number of data characters (21) cannot be 1 more than a multiple of 4 and _pickle.UnpicklingError: invalid load key, '%'. when decoding a grpc lib INTERNAL error

Related issue number

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Copy link
Contributor

@ijrsvt ijrsvt left a comment

Choose a reason for hiding this comment

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

@ckw017 Can you change this reference to use a different error code?

context.set_code(grpc.StatusCode.INVALID_ARGUMENT)

Copy link
Contributor

@ijrsvt ijrsvt left a comment

Choose a reason for hiding this comment

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

LGTM now!

# Note: https://grpc.github.io/grpc/core/md_doc_statuscodes.html
# INVALID_ARGUMENT used here since it should never be generated by the
# grpc lib -- this way we know the error was generated by ray logic
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
Copy link
Member

Choose a reason for hiding this comment

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

Would ABORTED be a more appropriate error code here? Conventions in my past team is to use ABORTED to signal application errors that are potentially retriable.

def decode_exception(data) -> Exception:
data = base64.standard_b64decode(data)
def decode_exception(e: grpc.RpcError) -> Exception:
if e.code() != grpc.StatusCode.INVALID_ARGUMENT:
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to match the full list from the reference you provided? Then using another GRPC error code from the list would still be correct.

Copy link
Member Author

@ckw017 ckw017 Sep 9, 2021

Choose a reason for hiding this comment

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

For this case, we should explicitly raise anything that isn't specifically the used in return_exception_in_context, otherwise we'll attempt to deserialize details that probably aren't a serialized ray exception, which would cause a deserialization error that obfuscates the real error.

@AmeerHajAli AmeerHajAli added the @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. label Sep 7, 2021
@ckw017 ckw017 requested a review from mwtian September 9, 2021 18:31
@ckw017 ckw017 removed the @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. label Sep 10, 2021
@ijrsvt ijrsvt merged commit 6f94d0f into ray-project:master Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants