-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make detection of S3 implementation more robust and handle slowly sta…
…rting S3 servers like MinIO
- Loading branch information
Showing
3 changed files
with
41 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package server | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/aws/client" | ||
"github.com/aws/aws-sdk-go/aws/request" | ||
) | ||
|
||
type retryer struct { | ||
client.DefaultRetryer | ||
} | ||
|
||
func (d retryer) RetryRules(r *request.Request) time.Duration { | ||
ra := r.HTTPResponse.Header.Get("Retry-after") | ||
svr := r.HTTPResponse.Header.Get("Server") | ||
|
||
// MinIO returns a "Retry-after: 120" header when the server is still initializing | ||
// Waiting 120 seconds is far too long as most servers finish their initialization faster | ||
// We reduce the time to 1 second and let the other retry rules handle the rest. | ||
if ra != "" && svr == "MinIO" && r.HTTPResponse.StatusCode == 503 { | ||
r.HTTPResponse.Header.Set("Retry-after", "1") | ||
} | ||
|
||
return d.DefaultRetryer.RetryRules(r) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters