audit/logger: Increase http request timeout (#12385)

A configured audit logger or HTTP logger is validated during MinIO
server startup. Relax the timeout to 10 seconds in that case, otherwise,
both loggers won't be used.

1 second could be too low for a busy HTTP endpoint.
This commit is contained in:
Anis Elleuch 2021-05-27 17:54:10 +01:00 committed by GitHub
parent e8a12cbfdd
commit 530b703902
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,9 @@ import (
"github.com/minio/minio/cmd/logger"
)
// Timeout for the webhook http call
const webhookCallTimeout = 5 * time.Second
// Target implements logger.Target and sends the json
// format of a log entry to the configured http endpoint.
// An internal buffer of logs is maintained but when the
@ -62,7 +65,7 @@ func (h *Target) String() string {
// Validate validate the http target
func (h *Target) Validate() error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 2*webhookCallTimeout)
defer cancel()
req, err := http.NewRequestWithContext(ctx, http.MethodPost, h.endpoint, strings.NewReader(`{}`))
@ -111,7 +114,7 @@ func (h *Target) startHTTPLogger() {
continue
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), webhookCallTimeout)
req, err := http.NewRequestWithContext(ctx, http.MethodPost,
h.endpoint, bytes.NewReader(logJSON))
if err != nil {