Skip to content

Commit

Permalink
Longer line lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
mattBrzezinski committed Mar 20, 2023
1 parent f960817 commit f5c8cc7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
10 changes: 3 additions & 7 deletions src/utilities/downloads_backend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,13 @@ function _http_request(backend::DownloadsBackend, request::Request, response_str

check = (s, e) -> begin
if isa(e, HTTP.StatusError) && AWS._http_status(e) >= 500
@debug "AWS.jl Downloads inner retry for status >= 500" retry = true reason = "status >= 500" status = AWS._http_status(
e
) exception = e
@debug "AWS.jl Downloads inner retry for status >= 500" retry=true reason="status >= 500" status=._http_status(e) exception=e
return true
elseif isa(e, Downloads.RequestError)
@debug "AWS.jl Downloads inner retry for Downloads.RequestError" retry =
true reason = "Downloads.RequestError" exception = e
@debug "AWS.jl Downloads inner retry for Downloads.RequestError" retry=true reason="Downloads.RequestError" exception=e
return true
else
@debug "AWS.jl Downloads inner retry declined" retry = false reason = "Exception passed onwards" exception =
e
@debug "AWS.jl Downloads inner retry declined" retry=false reason="Exception passed onwards" exception=e
return false
end
end
Expand Down
26 changes: 9 additions & 17 deletions src/utilities/request.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,19 @@ function submit_request(aws::AbstractAWSConfig, request::Request; return_headers
check = (s, e) -> begin
# Pass on non-AWS exceptions.
if !(e isa AWSException)
@debug "AWS.jl declined to retry non-AWSException" retry = false reason = "Non-AWSException" exception =
e
@debug "AWS.jl declined to retry non-AWSException" retry=false reason="Non-AWSException" exception=e
return false
end

if occursin("Signature expired", e.message)
@debug "AWS.jl retry for signature expired" retry = true reason = "Signature expired" exception =
e
@debug "AWS.jl retry for signature expired" retry=true reason="Signature expired" exception=e
return true
end

# Handle ExpiredToken...
# https://github.com/aws/aws-sdk-go/blob/v1.31.5/aws/request/retryer.go#L98
if e isa AWSException && e.code in EXPIRED_ERROR_CODES
@debug "AWS.jl retry for expired credentials" retry = true reason = "Credentials expired" exception =
e
@debug "AWS.jl retry for expired credentials" retry=true reason="Credentials expired" exception=e
check_credentials(credentials(aws); force_refresh=true)
return true
end
Expand All @@ -183,31 +180,27 @@ function submit_request(aws::AbstractAWSConfig, request::Request; return_headers
# https://github.com/boto/botocore/blob/1.16.17/botocore/data/_retry.json
# https://docs.aws.amazon.com/general/latest/gr/api-retries.html
if _http_status(e.cause) == TOO_MANY_REQUESTS
@debug "AWS.jl retry too many requests" retry = true reason = "too many requests" exception =
e
@debug "AWS.jl retry too many requests" retry=true reason="too many requests" exception=e
return true
elseif e.code in THROTTLING_ERROR_CODES
@debug "AWS.jl retry for throttling" retry = true reason = "throttled" exception =
e
@debug "AWS.jl retry for throttling" retry=true reason="throttled" exception=e
return true
end

# Handle BadDigest error and CRC32 check sum failure
if _header(e.cause, "crc32body") == "x-amz-crc32"
@debug "AWS.jl retry for check sum failure" retry = true reason = "Check sum failure" exception =
e
@debug "AWS.jl retry for check sum failure" retry=true reason="Check sum failure" exception=e
return true
end

if e.code in ("BadDigest", "RequestTimeout", "RequestTimeoutException")
@debug "AWS.jl retry for $(e.code)" retry = true reason = "$(e.code)" exception =
e
@debug "AWS.jl retry for $(e.code)" retry=true reason="$(e.code)" exception=e
return true
end

if occursin("Missing Authentication Token", e.message) &&
aws.credentials === nothing
@debug "AWS.jl declined to retry request without credentials" retry = false reason = "No credentials" exception = e
@debug "AWS.jl declined to retry request without credentials" retry=false reason="No credentials" exception=e

return throw(
NoCredentials(
Expand All @@ -216,8 +209,7 @@ function submit_request(aws::AbstractAWSConfig, request::Request; return_headers
)
end

@debug "AWS.jl declined to retry uncaught error" retry = false reason = "Error unhandled" exception =
e
@debug "AWS.jl declined to retry uncaught error" retry=false reason="Error unhandled" exception=e
return false
end

Expand Down
3 changes: 1 addition & 2 deletions test/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ BUCKET_NAME = "aws-jl-test-issues---" * _now_formatted()
function log_is_retry(successful)
return record ->
record.level == Logging.Debug &&
haskey(record.kwargs, :retry) &&
record.kwargs[:retry] == successful
get(record.kwargs, :retry, nothing) == successful
end

try
Expand Down

0 comments on commit f5c8cc7

Please sign in to comment.