14804: Returns 503 status (instead of 404) on GET when a volume does the same.
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Fri, 22 Feb 2019 18:59:32 +0000 (15:59 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Fri, 22 Feb 2019 18:59:32 +0000 (15:59 -0300)
Also, translates Azure's "...StatusCode=503..." error to VolumeBusyError.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

services/keepstore/azure_blob_volume.go
services/keepstore/handlers.go

index 5da2055b7736d117f6a7015a8486a948ee80a4d7..4f7339facf4ace001ac886a5076afc217e040c18 100644 (file)
@@ -603,6 +603,9 @@ func (v *AzureBlobVolume) translateError(err error) error {
        switch {
        case err == nil:
                return err
+       case strings.Contains(err.Error(), "StatusCode=503"):
+               // "storage: service returned error: StatusCode=503, ErrorCode=ServerBusy, ErrorMessage=The server is busy" (See #14804)
+               return VolumeBusyError
        case strings.Contains(err.Error(), "Not Found"):
                // "storage: service returned without a response body (404 Not Found)"
                return os.ErrNotExist
index e079b96784a16b985ed6ce47f99655e39a571ce9..2a1bbc972ffa6e4fe0675291b0c923efc4d4ac8d 100644 (file)
@@ -20,11 +20,10 @@ import (
        "sync"
        "time"
 
-       "github.com/gorilla/mux"
-
        "git.curoverse.com/arvados.git/sdk/go/arvados"
        "git.curoverse.com/arvados.git/sdk/go/health"
        "git.curoverse.com/arvados.git/sdk/go/httpserver"
+       "github.com/gorilla/mux"
 )
 
 type router struct {
@@ -669,6 +668,11 @@ func GetBlock(ctx context.Context, hash string, buf []byte, resp http.ResponseWr
                        if !os.IsNotExist(err) {
                                log.Printf("%s: Get(%s): %s", vol, hash, err)
                        }
+                       // If some volume returns a transient error, return it to the caller
+                       // instead of "Not found" so it can retry.
+                       if err == VolumeBusyError {
+                               errorToCaller = err.(*KeepError)
+                       }
                        continue
                }
                // Check the file checksum.