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

PUTing a full object to a resumable session does not trigger after instructions #510

Closed
BenWhitehead opened this issue Jun 12, 2023 · 2 comments · Fixed by #514
Closed
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@BenWhitehead
Copy link
Contributor

BenWhitehead commented Jun 12, 2023

PUTing a full object to a resumable session does not trigger after instructions such as return-503-after-256K[1].

after instructions appear to apply to the next request[2].

Environment details

  • Package version: gcr.io/cloud-devrel-public-resources/storage-testbench:v0.36.0

Steps to reproduce

# start the container
docker run --rm -d --name repro gcr.io/cloud-devrel-public-resources/storage-testbench:v0.36.0
# create a bucket
xh --print=h :9000/storage/v1/b project==project-id name=bucket1
# create the resumable upload session
{ uploadId=$(xh --print=h POST :9000/upload/storage/v1/b/bucket1/o name==object1 uploadType==resumable | tee /dev/fd/3 | grep -i 'Location:' | cut -b11-) ; } 3>&1
# upload 768KiB of data and finalize the session
dd ibs=262144 count=3 if=/dev/urandom | xh --print=Hh PUT "$uploadId" Content-Range:'bytes 0-786431/786432' x-goog-emulator-instructions:return-503-after-256K
# stop the docker container
docker kill repro

[1] https://gist.github.com/BenWhitehead/07b65f51ac6e0f6421d0a7f41a4d5433#file-01_result-txt-L12-L28
[2] https://gist.github.com/BenWhitehead/07b65f51ac6e0f6421d0a7f41a4d5433#file-02_result-txt-L38-L53

@BenWhitehead BenWhitehead added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jun 12, 2023
@cojenco
Copy link
Contributor

cojenco commented Jun 13, 2023

Is this referring to both the x-goog-emulator-instructions and Retry Test API in the testbench?

For the retry test instructions, I haven't had the chance to repro or investigate, but my first guess is that the after instructions are not triggered due to the current logic in handle_retry_test_instruction(). It relies on fetching len(upload.media) from the database in order to dequeue the instructions and force the failure.

upload = database.get_upload(upload_id, None)
if upload is not None and len(upload.media) >= after_bytes:
database.dequeue_next_instruction(test_id, method)
testbench.error.generic(
"Fault injected after uploading %d bytes" % len(upload.media),
rest_code=error_code,
grpc_code=StatusCode.INTERNAL, # not really used
context=None,
)

@BenWhitehead
Copy link
Contributor Author

I've observed the same behavior for x-goog-emulator-instructions:return-503-after-256K or for /retry_test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants