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

chore(storage): replace Canceled status with context.Canceled #4896

Merged
merged 3 commits into from
Oct 5, 2021

Conversation

noahdietz
Copy link
Contributor

The gRPC Storage client replaces Canceled statuses with context.Canceled to conform to what JSON does.

Unskip the CancelWriteGRPC test by fixing the Canceled status handling and updating the test to provoke network calls using after cancelation, resulting in Write errors. See notes in #4772 WRT the context cancelation race condition behavior.

Fixes #4772

@noahdietz noahdietz requested review from a team as code owners September 27, 2021 23:58
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Sep 27, 2021
@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Sep 27, 2021
@@ -637,3 +642,11 @@ func read(r io.Reader, buf []byte) (int, bool, error) {
}
return recvd, done, err
}

func checkCanceled(err error) error {
if status.Code(err) == codes.Canceled {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like the right thing to do, but just to check: are we ever losing any information here by obscuring the difference between a user-side context cancelation and the RPC call returning codes.Canceled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We might be, but I'm not entirely sure. I don't think we would be since this error is induced by client-side request settings i.e. the user sets a deadline on the context, and the server notices that the deadline it received has expired. Nothing for the server to add there imo.

One other option would be to change how gax.APIError handles codes.Canceled and instead of storing the original grpc-go error, it stores a context.Canceled after parsing the Status. But that's a bit more far reaching and I'd be hesitant to do that.

@noahdietz noahdietz merged commit 299b368 into googleapis:master Oct 5, 2021
@noahdietz noahdietz deleted the storage-cancel-test branch October 5, 2021 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

storage: TestIntegration_CancelWriteGRPC failed
2 participants