in s3plugin/s3plugin.go [192:224]
func (r CustomRetryer) ShouldRetry(req *request.Request) bool {
if r.NumMaxRetries == 0 {
return false
}
willRetry := false
if req.Error != nil && strings.Contains(req.Error.Error(), "connection reset by peer") {
willRetry = true
} else if req.HTTPResponse.StatusCode == 404 && strings.Contains(req.Error.Error(), "NoSuchKey") {
// 404 NoSuchKey error is possible due to AWS's eventual consistency
// when attempting to inspect or get a file too quickly after it was
// uploaded. The s3 plugin does exactly this to determine the amount of
// bytes uploaded. For this reason we retry 404 errors.
willRetry = true
} else {
willRetry = r.DefaultRetryer.ShouldRetry(req)
}
if willRetry {
// While its possible to let the AWS client log for us, it doesn't seem
// possible to set it up to only log errors. To prevent our log from
// filling up with debug logs of successful https requests and
// response, we'll only log when retries are attempted.
if req.Error != nil {
gplog.Debug("Https request attempt %d failed. Next attempt in %v. %s\n", req.RetryCount, r.RetryRules(req), req.Error.Error())
} else {
gplog.Debug("Https request attempt %d failed. Next attempt in %v.\n", req.RetryCount, r.RetryRules(req))
}
return true
}
return false
}