From f18bd1860cc99d3082d19daf1a3419725cd61228 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:58:00 +0000 Subject: [PATCH] fix(deps): update module google.golang.org/api to v0.208.0 --- go.mod | 2 +- go.sum | 4 +-- .../api/googleapi/googleapi.go | 15 ++++++++++ .../api/internal/gensupport/media.go | 19 +++++++------ .../api/internal/gensupport/resumable.go | 28 ++++++++++++++++++- .../google.golang.org/api/internal/version.go | 2 +- vendor/modules.txt | 2 +- 7 files changed, 58 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 15bf63b859d42..fe39d22eb5298 100644 --- a/go.mod +++ b/go.mod @@ -103,7 +103,7 @@ require ( golang.org/x/sync v0.9.0 golang.org/x/sys v0.27.0 golang.org/x/time v0.8.0 - google.golang.org/api v0.207.0 + google.golang.org/api v0.208.0 google.golang.org/grpc v1.68.0 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index b50d624279b46..e170905ac4b65 100644 --- a/go.sum +++ b/go.sum @@ -3489,8 +3489,8 @@ google.golang.org/api v0.122.0/go.mod h1:gcitW0lvnyWjSp9nKxAbdHKIZ6vF4aajGueeslZ google.golang.org/api v0.124.0/go.mod h1:xu2HQurE5gi/3t1aFCvhPD781p0a3p11sdunTJ2BlP4= google.golang.org/api v0.125.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= -google.golang.org/api v0.207.0 h1:Fvt6IGCYjf7YLcQ+GCegeAI2QSQCfIWhRkmrMPj3JRM= -google.golang.org/api v0.207.0/go.mod h1:I53S168Yr/PNDNMi5yPnDc0/LGRZO6o7PoEbl/HY3CM= +google.golang.org/api v0.208.0 h1:8Y62MUGRviQnnP9/41/bYAGySPKAN9iwzV96ZvhwyVE= +google.golang.org/api v0.208.0/go.mod h1:I53S168Yr/PNDNMi5yPnDc0/LGRZO6o7PoEbl/HY3CM= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/vendor/google.golang.org/api/googleapi/googleapi.go b/vendor/google.golang.org/api/googleapi/googleapi.go index b5e38c662820c..04a10f51c979f 100644 --- a/vendor/google.golang.org/api/googleapi/googleapi.go +++ b/vendor/google.golang.org/api/googleapi/googleapi.go @@ -259,6 +259,20 @@ func ChunkSize(size int) MediaOption { return chunkSizeOption(size) } +type chunkTransferTimeoutOption time.Duration + +func (cd chunkTransferTimeoutOption) setOptions(o *MediaOptions) { + o.ChunkTransferTimeout = time.Duration(cd) +} + +// ChunkTransferTimeout returns a MediaOption which sets a per-chunk +// transfer timeout for resumable uploads. If a single chunk has been +// attempting to upload for longer than this time then the old req got canceled and retried. +// The default is no timeout for the request. +func ChunkTransferTimeout(timeout time.Duration) MediaOption { + return chunkTransferTimeoutOption(timeout) +} + type chunkRetryDeadlineOption time.Duration func (cd chunkRetryDeadlineOption) setOptions(o *MediaOptions) { @@ -283,6 +297,7 @@ type MediaOptions struct { ForceEmptyContentType bool ChunkSize int ChunkRetryDeadline time.Duration + ChunkTransferTimeout time.Duration } // ProcessMediaOptions stores options from opts in a MediaOptions. diff --git a/vendor/google.golang.org/api/internal/gensupport/media.go b/vendor/google.golang.org/api/internal/gensupport/media.go index c048a57084b8d..0861d4d3c872c 100644 --- a/vendor/google.golang.org/api/internal/gensupport/media.go +++ b/vendor/google.golang.org/api/internal/gensupport/media.go @@ -135,13 +135,14 @@ func PrepareUpload(media io.Reader, chunkSize int) (r io.Reader, mb *MediaBuffer // code only. type MediaInfo struct { // At most one of Media and MediaBuffer will be set. - media io.Reader - buffer *MediaBuffer - singleChunk bool - mType string - size int64 // mediaSize, if known. Used only for calls to progressUpdater_. - progressUpdater googleapi.ProgressUpdater - chunkRetryDeadline time.Duration + media io.Reader + buffer *MediaBuffer + singleChunk bool + mType string + size int64 // mediaSize, if known. Used only for calls to progressUpdater_. + progressUpdater googleapi.ProgressUpdater + chunkRetryDeadline time.Duration + chunkTransferTimeout time.Duration } // NewInfoFromMedia should be invoked from the Media method of a call. It returns a @@ -157,6 +158,7 @@ func NewInfoFromMedia(r io.Reader, options []googleapi.MediaOption) *MediaInfo { } } mi.chunkRetryDeadline = opts.ChunkRetryDeadline + mi.chunkTransferTimeout = opts.ChunkTransferTimeout mi.media, mi.buffer, mi.singleChunk = PrepareUpload(r, opts.ChunkSize) return mi } @@ -294,7 +296,8 @@ func (mi *MediaInfo) ResumableUpload(locURI string) *ResumableUpload { mi.progressUpdater(curr, mi.size) } }, - ChunkRetryDeadline: mi.chunkRetryDeadline, + ChunkRetryDeadline: mi.chunkRetryDeadline, + ChunkTransferTimeout: mi.chunkTransferTimeout, } } diff --git a/vendor/google.golang.org/api/internal/gensupport/resumable.go b/vendor/google.golang.org/api/internal/gensupport/resumable.go index f828ddb60e6df..9e3bcf1596385 100644 --- a/vendor/google.golang.org/api/internal/gensupport/resumable.go +++ b/vendor/google.golang.org/api/internal/gensupport/resumable.go @@ -43,6 +43,10 @@ type ResumableUpload struct { // retries should happen. ChunkRetryDeadline time.Duration + // ChunkTransferTimeout configures the per-chunk transfer timeout. If a chunk upload stalls for longer than + // this duration, the upload will be retried. + ChunkTransferTimeout time.Duration + // Track current request invocation ID and attempt count for retry metrics // and idempotency headers. invocationID string @@ -241,13 +245,35 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err default: } - resp, err = rx.transferChunk(ctx) + // rCtx is derived from a context with a defined transferTimeout with non-zero value. + // If a particular request exceeds this transfer time for getting response, the rCtx deadline will be exceeded, + // triggering a retry of the request. + var rCtx context.Context + var cancel context.CancelFunc + + rCtx = ctx + if rx.ChunkTransferTimeout != 0 { + rCtx, cancel = context.WithTimeout(ctx, rx.ChunkTransferTimeout) + } + + resp, err = rx.transferChunk(rCtx) var status int if resp != nil { status = resp.StatusCode } + // The upload should be retried if the rCtx is canceled due to a timeout. + select { + case <-rCtx.Done(): + if errors.Is(rCtx.Err(), context.DeadlineExceeded) { + // Cancel the context for rCtx + cancel() + continue + } + default: + } + // Check if we should retry the request. if !errorFunc(status, err) { quitAfterTimer.Stop() diff --git a/vendor/google.golang.org/api/internal/version.go b/vendor/google.golang.org/api/internal/version.go index 294436d31c458..796b74a86fd4e 100644 --- a/vendor/google.golang.org/api/internal/version.go +++ b/vendor/google.golang.org/api/internal/version.go @@ -5,4 +5,4 @@ package internal // Version is the current tagged release of the library. -const Version = "0.207.0" +const Version = "0.208.0" diff --git a/vendor/modules.txt b/vendor/modules.txt index d4483761ccbfa..cf631994d01f0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1934,7 +1934,7 @@ golang.org/x/tools/internal/stdlib golang.org/x/tools/internal/tokeninternal golang.org/x/tools/internal/typesinternal golang.org/x/tools/internal/versions -# google.golang.org/api v0.207.0 +# google.golang.org/api v0.208.0 ## explicit; go 1.21 google.golang.org/api/cloudresourcemanager/v1 google.golang.org/api/compute/v1