diff options
| author | Jonathan Amsterdam <jba@google.com> | 2021-02-19 06:29:29 -0500 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2021-02-19 12:51:20 +0000 |
| commit | 4327d65345ea4033438ed8c15031e8bee1b96fb5 (patch) | |
| tree | 84b77c67cd8cb04155d519d29eb336d78ab62edb /internal/queue/queue.go | |
| parent | bdbff71810517c1204374ab25b79368cc5631340 (diff) | |
| download | go-x-pkgsite-4327d65345ea4033438ed8c15031e8bee1b96fb5.tar.xz | |
internal/queue: restore CreateTask timeout
It turns out that the comment in ScheduleFetch was right: CreateTask
does require a timeout of at most 30s.
Change-Id: I2cc8086247bf606b054132a2908b705f20ecd490
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/294089
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'internal/queue/queue.go')
| -rw-r--r-- | internal/queue/queue.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/internal/queue/queue.go b/internal/queue/queue.go index 6cbf019a..c77f3b52 100644 --- a/internal/queue/queue.go +++ b/internal/queue/queue.go @@ -117,6 +117,13 @@ func newGCP(cfg *config.Config, client *cloudtasks.Client, queueID string) (_ *G func (q *GCP) ScheduleFetch(ctx context.Context, modulePath, version, suffix string, disableProxyFetch bool) (enqueued bool, err error) { defer derrors.WrapStack(&err, "queue.ScheduleFetch(%q, %q, %q)", modulePath, version, suffix) + // Cloud Tasks enforces an RPC timeout of at most 30s. I couldn't find this + // in the documentation, but using a larger value, or no timeout, results in + // an InvalidArgument error with the text "The deadline cannot be more than + // 30s in the future." + ctx, cancel := context.WithTimeout(ctx, 30*time.Second) + defer cancel() + req := q.newTaskRequest(modulePath, version, suffix, disableProxyFetch) enqueued = true if _, err := q.client.CreateTask(ctx, req); err != nil { |
