aboutsummaryrefslogtreecommitdiff
path: root/internal/queue/queue.go
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2020-09-29 06:14:34 -0400
committerJonathan Amsterdam <jba@google.com>2020-09-29 15:35:17 +0000
commite91ba8014eec837f43b0ba7ffaf857a9b62b1a82 (patch)
tree479bc2d3e1b26d1863770d0d469b390e3717362d /internal/queue/queue.go
parent8962bff2e39e2bc62ea9222416113b8067358674 (diff)
downloadgo-x-pkgsite-e91ba8014eec837f43b0ba7ffaf857a9b62b1a82.tar.xz
internal/queue: increase task timeout
HTTP tasks (but not AppEngine tasks) have a default timeout of 10 minutes. Extend that to the maximum of 30 minutes. Change-Id: I75efc0523ff83471a0a2a8d453e1284483feefe1 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/258197 Reviewed-by: Julie Qiu <julie@golang.org> Trust: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'internal/queue/queue.go')
-rw-r--r--internal/queue/queue.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/queue/queue.go b/internal/queue/queue.go
index 64bbfae9..229631f5 100644
--- a/internal/queue/queue.go
+++ b/internal/queue/queue.go
@@ -14,6 +14,7 @@ import (
"time"
cloudtasks "cloud.google.com/go/cloudtasks/apiv2"
+ "github.com/golang/protobuf/ptypes"
"golang.org/x/pkgsite/internal/config"
"golang.org/x/pkgsite/internal/derrors"
"golang.org/x/pkgsite/internal/experiment"
@@ -139,10 +140,17 @@ func (q *GCP) ScheduleFetch(ctx context.Context, modulePath, version, suffix str
return enqueued, nil
}
+// Maximum timeout for HTTP tasks.
+// See https://cloud.google.com/tasks/docs/creating-http-target-tasks.
+const maxCloudTasksTimeout = 30 * time.Minute
+
func (q *GCP) newTaskRequest(modulePath, version, suffix string, taskIDChangeInterval time.Duration) *taskspb.CreateTaskRequest {
taskID := newTaskID(modulePath, version, time.Now(), taskIDChangeInterval)
relativeURI := fmt.Sprintf("/fetch/%s/@v/%s", modulePath, version)
- task := &taskspb.Task{Name: fmt.Sprintf("%s/tasks/%s", q.queueName, taskID)}
+ task := &taskspb.Task{
+ Name: fmt.Sprintf("%s/tasks/%s", q.queueName, taskID),
+ DispatchDeadline: ptypes.DurationProto(maxCloudTasksTimeout),
+ }
if q.queueService != "" {
task.MessageType = &taskspb.Task_AppEngineHttpRequest{
AppEngineHttpRequest: &taskspb.AppEngineHttpRequest{