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

Upload to gcs using go client doesn't error but uploads zero bytes #746

Closed
dneralla opened this issue Aug 30, 2017 · 6 comments
Closed

Upload to gcs using go client doesn't error but uploads zero bytes #746

dneralla opened this issue Aug 30, 2017 · 6 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@dneralla
Copy link

dneralla commented Aug 30, 2017

Hi We are facing a issue where the uploader is uploading 0 bytes.

Per @jba comment
#724 (comment)

That goes through that path when the content being uploaded is greater than chunksize per
https://github.com/google/google-api-go-client/blob/master/storage/v1/storage-gen.go#L8751

And MediaBuffer is only created when content is greater than chunk size for resumable upload, per
https://github.com/google/google-api-go-client/blob/master/gensupport/media.go#L191

What happens on retries when it doesn't go through resumable upload ?

@dneralla
Copy link
Author

Was able to simulate by doing so as I mentioned in

#724 (comment)

@dneralla dneralla changed the title Upload passes but uploads zero bytes Upload to gcs using go client doesn't error but uploads zero bytes Aug 30, 2017
@jba jba self-assigned this Sep 5, 2017
@jba jba added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. api: storage Issues related to the Cloud Storage API. labels Sep 5, 2017
@jba
Copy link
Contributor

jba commented Sep 6, 2017

I can reproduce, and I think I know what the problem is. Working on a fix. Meanwhile, you can work around by setting Writer.ChunkSize small.

@dneralla
Copy link
Author

dneralla commented Sep 7, 2017

I worked around with using media buffer for everything, changed a line of code in our vendor libs directory. Thanks though

@jba
Copy link
Contributor

jba commented Sep 7, 2017

How did you do it with one line? It took me a few (https://code-review.googlesource.com/c/google-api-go-client/+/16570).

@dneralla
Copy link
Author

dneralla commented Sep 8, 2017

I just ignored the EOF error.

func PrepareUpload(media io.Reader, chunkSize int) (r io.Reader, mb *MediaBuffer) { if chunkSize == 0 { // do not chunk return media, nil, true } mb = NewMediaBuffer(media, chunkSize) mb.Chunk() return nil, mb }

@jba
Copy link
Contributor

jba commented Sep 8, 2017

That's fine. You'll do an extra call to the server for one-chunk uploads, which I try to avoid, but otherwise it should work.

gopherbot pushed a commit that referenced this issue Sep 12, 2017
A couple of changes related the fix for single-chunk retry in
https://code-review.googlesource.com/16570.

- A test that exhibits the bug (zero-length data on retry).
- Avoid retry when chunk size = 0 (explanation in above CL).

Fixes #746.

Change-Id: I139e94852fc4d842d4d51be49b8bedac6420aa7e
Reviewed-on: https://code-review.googlesource.com/16571
Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ross Light <light@google.com>
maxlazio pushed a commit to gitlabhq/omnibus-gitlab that referenced this issue Oct 22, 2019
v2.7.2-gitlab has the patch to enable MD5 checksums on top of v2.7.1.
This change is done for a number of reasons:

1. To prepare for future changes in the GitLab Container Registry
2. To get the version number right (e.g. v2.7.2-gitlab instead of
v2.7.1.m)
3. To make the build consistent with the one used by the cloud-native
container.

v2.7.3-gitlab updates the storage driver to use the latest Google SDK:
https://gitlab.com/gitlab-org/container-registry/merge_requests/2

v2.7.4-gitlab fixes an issues with v2.7.3-gitlab with non-default
Google credentials:
https://gitlab.com/gitlab-org/container-registry/merge_requests/7

This registry upgrade hopefully will fix 0-byte upload issues:
googleapis/google-cloud-go#746
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. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to 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