From 5b29321afc87a0e1a0c277cd862ffcde18049549 Mon Sep 17 00:00:00 2001 From: Max Holland Date: Thu, 5 Sep 2024 10:20:46 +0100 Subject: [PATCH] Increase timeout for write permission check (#1379) I'm seeing this fail occasionally in prod since storage providers can be a bit slow even with a small json file --- clients/object_store_client.go | 3 +-- handlers/upload.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/clients/object_store_client.go b/clients/object_store_client.go index 4524dd82e..b33c65cd6 100644 --- a/clients/object_store_client.go +++ b/clients/object_store_client.go @@ -6,7 +6,6 @@ import ( "fmt" "io" "net/url" - "path/filepath" "strings" "time" @@ -89,7 +88,7 @@ func UploadToOSURLFields(osURL, filename string, data io.Reader, timeout time.Du if err != nil { metrics.Metrics.ObjectStoreClient.FailureCount.WithLabelValues(host, "write", bucket).Inc() - return fmt.Errorf("failed to write to OS URL %q: %s", log.RedactURL(filepath.Join(osURL, filename)), err) + return fmt.Errorf("failed to write to OS URL %q: %s", log.RedactURL(osURL+"/"+filename), err) } duration := time.Since(start) diff --git a/handlers/upload.go b/handlers/upload.go index 9b4d80652..49899cc7f 100644 --- a/handlers/upload.go +++ b/handlers/upload.go @@ -360,7 +360,7 @@ func checkWritePermission(reqID, externalID string, urls ...*url.URL) error { urlString := u.String() // check write permission by uploading a file - err := clients.UploadToOSURL(u.String(), "metadata.json", strings.NewReader(fmt.Sprintf(`{"external_id": "%s"}`, externalID)), time.Second) + err := clients.UploadToOSURL(u.String(), "metadata.json", strings.NewReader(fmt.Sprintf(`{"external_id": "%s"}`, externalID)), 30*time.Second) if err != nil { log.LogError(reqID, "failed write permission check", err, "url", log.RedactURL(urlString)) return fmt.Errorf("failed write permission check for %s", log.RedactURL(urlString))