Explorar el Código

s3api: Better handle 498/429 responses

Currently, they just 500 as an unexpected response status. Much better
would be S3's '503 Slow Down' response.

Of course, that's all dependent on where you place ratelimit in your
pipeline -- and we haven't really given clear guidance on that. I'm not
actually sure you *want* ratelimit to be after s3api and auth... but if
you *do*, let's at least handle it gracefully.

Change-Id: I36f0954fd9949d7d1404a0c381b917d1cfb17ec5
Related-Bug: 1669888
(cherry picked from commit f33c061ae92f33ea467c58749d3f15d2b1cc942c)
changes/59/704659/1
Tim Burke hace 4 meses
padre
commit
778767f324
Se han modificado 2 ficheros con 5 adiciones y 2 borrados
  1. +1
    -0
      swift/common/http.py
  2. +4
    -2
      swift/common/middleware/s3api/s3request.py

+ 1
- 0
swift/common/http.py Ver fichero

@@ -138,6 +138,7 @@ HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431
HTTP_NO_RESPONSE = 444
HTTP_RETRY_WITH = 449
HTTP_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS = 450
HTTP_RATE_LIMITED = 498
HTTP_CLIENT_CLOSED_REQUEST = 499

###############################################################################


+ 4
- 2
swift/common/middleware/s3api/s3request.py Ver fichero

@@ -33,7 +33,7 @@ from swift.common.http import HTTP_OK, HTTP_CREATED, HTTP_ACCEPTED, \
HTTP_PARTIAL_CONTENT, HTTP_NOT_MODIFIED, HTTP_PRECONDITION_FAILED, \
HTTP_REQUESTED_RANGE_NOT_SATISFIABLE, HTTP_LENGTH_REQUIRED, \
HTTP_BAD_REQUEST, HTTP_REQUEST_TIMEOUT, HTTP_SERVICE_UNAVAILABLE, \
is_success
HTTP_TOO_MANY_REQUESTS, HTTP_RATE_LIMITED, is_success

from swift.common.constraints import check_utf8
from swift.proxy.controllers.base import get_container_info, \
@@ -52,7 +52,7 @@ from swift.common.middleware.s3api.s3response import AccessDenied, \
InternalError, NoSuchBucket, NoSuchKey, PreconditionFailed, InvalidRange, \
MissingContentLength, InvalidStorageClass, S3NotImplemented, InvalidURI, \
MalformedXML, InvalidRequest, RequestTimeout, InvalidBucketName, \
BadDigest, AuthorizationHeaderMalformed, \
BadDigest, AuthorizationHeaderMalformed, SlowDown, \
AuthorizationQueryParametersError, ServiceUnavailable
from swift.common.middleware.s3api.exception import NotS3Request, \
BadSwiftRequest
@@ -1362,6 +1362,8 @@ class S3Request(swob.Request):
raise AccessDenied()
if status == HTTP_SERVICE_UNAVAILABLE:
raise ServiceUnavailable()
if status in (HTTP_RATE_LIMITED, HTTP_TOO_MANY_REQUESTS):
raise SlowDown()

raise InternalError('unexpected status code %d' % status)



Cargando…
Cancelar
Guardar