aboutsummaryrefslogtreecommitdiff
path: root/internal/queue/queue.go
diff options
context:
space:
mode:
authorJulie Qiu <julie@golang.org>2020-04-28 00:25:42 -0400
committerJulie Qiu <julieqiu@google.com>2020-04-30 01:48:31 +0000
commit3c5ea2343246e593f11750c8bc9c0c6d1ddcc8a0 (patch)
tree72220c2fe0eccbf031c0da534075b20954979fc5 /internal/queue/queue.go
parenta2fccc79ef7d3ad20edee54e59249a02b6219e75 (diff)
downloadgo-x-pkgsite-3c5ea2343246e593f11750c8bc9c0c6d1ddcc8a0.tar.xz
internal/worker: improve error messages and logs
Error messages returned by requests to the worker are cleaned up. Change-Id: I79354eafc8785bbffd4bc1fb6db93cee7b517371 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/729941 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'internal/queue/queue.go')
-rw-r--r--internal/queue/queue.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/internal/queue/queue.go b/internal/queue/queue.go
index 9242595d..baabe919 100644
--- a/internal/queue/queue.go
+++ b/internal/queue/queue.go
@@ -15,6 +15,7 @@ import (
cloudtasks "cloud.google.com/go/cloudtasks/apiv2"
"golang.org/x/pkgsite/internal/config"
+ "golang.org/x/pkgsite/internal/derrors"
"golang.org/x/pkgsite/internal/log"
"golang.org/x/pkgsite/internal/postgres"
"golang.org/x/pkgsite/internal/proxy"
@@ -51,12 +52,14 @@ func NewGCP(cfg *config.Config, client *cloudtasks.Client, queueID string) *GCP
// ScheduleFetch enqueues a task on GCP to fetch the given modulePath and
// version. It returns an error if there was an error hashing the task name, or
// an error pushing the task to GCP.
-func (q *GCP) ScheduleFetch(ctx context.Context, modulePath, version, suffix string) error {
+func (q *GCP) ScheduleFetch(ctx context.Context, modulePath, version, suffix string) (err error) {
// the new taskqueue API requires a deadline of <= 30s
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
+ defer derrors.Wrap(&err, "queue.ScheduleFetch(%q, %q, %q)", modulePath, version, suffix)
queueName := fmt.Sprintf("projects/%s/locations/%s/queues/%s", q.cfg.ProjectID, q.cfg.LocationID, q.queueID)
- u := fmt.Sprintf("/fetch/%s/@v/%s", modulePath, version)
+ mod := fmt.Sprintf("%s/@v/%s", modulePath, version)
+ u := fmt.Sprintf("/fetch/" + mod)
taskID := newTaskID(modulePath, version, time.Now())
req := &taskspb.CreateTaskRequest{
Parent: queueName,
@@ -81,7 +84,7 @@ func (q *GCP) ScheduleFetch(ctx context.Context, modulePath, version, suffix str
if _, err := q.client.CreateTask(ctx, req); err != nil {
if status.Code(err) == codes.AlreadyExists {
- log.Infof(ctx, "ignoring duplicate task ID %s", taskID)
+ log.Infof(ctx, "ignoring duplicate task ID %s: %q", taskID, mod)
} else {
return fmt.Errorf("q.client.CreateTask(ctx, req): %v", err)
}