aboutsummaryrefslogtreecommitdiff
path: root/internal/queue/queue.go
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2021-02-19 06:29:29 -0500
committerJonathan Amsterdam <jba@google.com>2021-02-19 12:51:20 +0000
commit4327d65345ea4033438ed8c15031e8bee1b96fb5 (patch)
tree84b77c67cd8cb04155d519d29eb336d78ab62edb /internal/queue/queue.go
parentbdbff71810517c1204374ab25b79368cc5631340 (diff)
downloadgo-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.go7
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 {