Skip to content

Commit

Permalink
retry always, add aws logging (#757)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostbyte73 authored Aug 15, 2024
1 parent 30059b4 commit 0fbc019
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion pkg/config/uploads.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ func (c StorageConfig) ToUploadConfig() UploadConfig {

// Handle AWS log level
switch c.S3.AwsLogLevel {
case "LogOff":
s3.AwsLogLevel = aws.LogOff
case "LogDebugWithRequestRetries":
s3.AwsLogLevel = aws.LogDebugWithRequestRetries
case "LogDebug":
Expand All @@ -117,7 +119,7 @@ func (c StorageConfig) ToUploadConfig() UploadConfig {
case "LogDebugWithSigning":
s3.AwsLogLevel = aws.LogDebugWithSigning
default:
s3.AwsLogLevel = aws.LogOff
s3.AwsLogLevel = aws.LogDebugWithRequestRetries | aws.LogDebugWithRequestErrors
}

return s3
Expand Down
16 changes: 10 additions & 6 deletions pkg/pipeline/sink/uploader/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ type CustomRetryer struct {
}

// ShouldRetry overrides the SDK's built in DefaultRetryer because the PUTs for segments/playlists are always idempotent
func (r CustomRetryer) ShouldRetry(req *request.Request) bool {
// if the request failed due to a 401 or 403, don't retry
if req.HTTPResponse.StatusCode == http.StatusUnauthorized || req.HTTPResponse.StatusCode == http.StatusForbidden {
return false
}
func (r CustomRetryer) ShouldRetry(_ *request.Request) bool {
return true
}

Expand All @@ -75,8 +71,16 @@ func newS3Uploader(conf *config.EgressS3Upload) (uploader, error) {
},
},
S3ForcePathStyle: aws.Bool(conf.ForcePathStyle),
LogLevel: aws.LogLevel(conf.AwsLogLevel),
LogLevel: &conf.AwsLogLevel,
Logger: aws.LoggerFunc(func(args ...interface{}) {
msg := "aws sdk:"
for range len(args) {
msg += " %v"
}
logger.Debugw(fmt.Sprintf(msg, args...))
}),
}

logger.Debugw("setting S3 config",
"maxRetries", conf.MaxRetries,
"maxDelay", conf.MaxRetryDelay,
Expand Down

0 comments on commit 0fbc019

Please sign in to comment.