Skip to content

Commit

Permalink
Increase timeout for write permission check (#1379)
Browse files Browse the repository at this point in the history
I'm seeing this fail occasionally in prod since storage providers can be a bit slow even with a small json file
  • Loading branch information
mjh1 authored Sep 5, 2024
1 parent 3ad23fb commit 5b29321
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions clients/object_store_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"io"
"net/url"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion handlers/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 5b29321

Please sign in to comment.