21023: Avoid overloading 503 status.
authorTom Clegg <tom@curii.com>
Thu, 18 Jan 2024 19:04:26 +0000 (14:04 -0500)
committerTom Clegg <tom@curii.com>
Tue, 13 Feb 2024 15:33:34 +0000 (10:33 -0500)
When all volumes are full, return 507 (cf WebDAV) indicating the
client should not auto-retry without additional user interaction.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

services/keepstore/handler_test.go
services/keepstore/handlers.go
services/keepstore/keepstore.go

index 5bdafb77c2f8fdf13de772cb44920a9b1c191619..4352d9a54a392d74a4a10b6a1245992cd5c3bbbf 100644 (file)
@@ -198,7 +198,7 @@ func (s *HandlerSuite) TestGetHandler(c *check.C) {
        // should make the service return a 503 so that clients can retry.
        ExpectStatusCode(c,
                "Volume backend busy",
-               503, response)
+               http.StatusServiceUnavailable, response)
 }
 
 // Test PutBlockHandler on the following situations:
@@ -1270,7 +1270,7 @@ func (s *HandlerSuite) TestPutStorageClasses(c *check.C) {
                c.Logf("failure case %#v", trial)
                rt.storageClasses = trial.ask
                resp := IssueRequest(s.handler, &rt)
-               c.Check(resp.Code, check.Equals, http.StatusServiceUnavailable)
+               c.Check(resp.Code, check.Equals, http.StatusInsufficientStorage)
        }
 }
 
index abeb20fe8624a79dfbe0b38159fa98a51119ae39..089ebb46da973a34942c23f0ae7ff751686df63d 100644 (file)
@@ -853,7 +853,7 @@ func newPutProgress(classes []string) putProgress {
 //
 //     The MD5 hash of the BLOCK does not match the argument HASH.
 //
-// 503 Full
+// 507 Full
 //
 //     There was not enough space left in any Keep volume to store
 //     the object.
index 953aa047cbfa6ab6f7b55630aa30e83732adaf0e..46b00339b5f8d9ff6dcbe3213b9cb1031004063c 100644 (file)
@@ -5,6 +5,7 @@
 package keepstore
 
 import (
+       "net/http"
        "time"
 )
 
@@ -23,22 +24,22 @@ type KeepError struct {
 }
 
 var (
-       BadRequestError     = &KeepError{400, "Bad Request"}
-       UnauthorizedError   = &KeepError{401, "Unauthorized"}
-       CollisionError      = &KeepError{500, "Collision"}
-       RequestHashError    = &KeepError{422, "Hash mismatch in request"}
-       PermissionError     = &KeepError{403, "Forbidden"}
-       DiskHashError       = &KeepError{500, "Hash mismatch in stored data"}
-       ExpiredError        = &KeepError{401, "Expired permission signature"}
-       NotFoundError       = &KeepError{404, "Not Found"}
-       VolumeBusyError     = &KeepError{503, "Volume backend busy"}
-       GenericError        = &KeepError{500, "Fail"}
-       FullError           = &KeepError{503, "Full"}
-       SizeRequiredError   = &KeepError{411, "Missing Content-Length"}
-       TooLongError        = &KeepError{413, "Block is too large"}
-       MethodDisabledError = &KeepError{405, "Method disabled"}
-       ErrNotImplemented   = &KeepError{500, "Unsupported configuration"}
-       ErrClientDisconnect = &KeepError{503, "Client disconnected"}
+       BadRequestError     = &KeepError{http.StatusBadRequest, "Bad Request"}
+       UnauthorizedError   = &KeepError{http.StatusUnauthorized, "Unauthorized"}
+       CollisionError      = &KeepError{http.StatusInternalServerError, "Collision"}
+       RequestHashError    = &KeepError{http.StatusUnprocessableEntity, "Hash mismatch in request"}
+       PermissionError     = &KeepError{http.StatusForbidden, "Forbidden"}
+       DiskHashError       = &KeepError{http.StatusInternalServerError, "Hash mismatch in stored data"}
+       ExpiredError        = &KeepError{http.StatusUnauthorized, "Expired permission signature"}
+       NotFoundError       = &KeepError{http.StatusNotFound, "Not Found"}
+       VolumeBusyError     = &KeepError{http.StatusServiceUnavailable, "Volume backend busy"}
+       GenericError        = &KeepError{http.StatusInternalServerError, "Fail"}
+       FullError           = &KeepError{http.StatusInsufficientStorage, "Full"}
+       SizeRequiredError   = &KeepError{http.StatusLengthRequired, "Missing Content-Length"}
+       TooLongError        = &KeepError{http.StatusRequestEntityTooLarge, "Block is too large"}
+       MethodDisabledError = &KeepError{http.StatusMethodNotAllowed, "Method disabled"}
+       ErrNotImplemented   = &KeepError{http.StatusInternalServerError, "Unsupported configuration"}
+       ErrClientDisconnect = &KeepError{499, "Client disconnected"} // non-RFC Nginx status code
 )
 
 func (e *KeepError) Error() string {